What does "not run" mean in R help pages?

Viewed 23091

Sometimes on an R help page the phrase "not run" appears in comments. Check out this from the help page for "with()":

Examples
require(stats); require(graphics)
#examples from glm:
**## Not run:** 
library(MASS)
with(anorexia, {
    anorex.1 <- glm(Postwt ~ Prewt + Treat + offset(Prewt),
                    family = gaussian)
    summary(anorex.1)
})
## End(**Not run**)

What does the "not run" mean in the example code?

5 Answers

The canonical example here might be in the help page for rm:

## Not run: 
## remove (almost) everything in the working environment.
## You will get no warning, so don't do this unless you are really sure.
rm(list = ls())

## End(Not run)

If this ran it would of course have undesired effects.

Related