Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in R Programming by (5.3k points)

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?

1 Answer

0 votes
by

In R help pages, the statement "Not run" encloses code that shouldn't be executed in the example function. This is usually the code that is time-consuming, user-interactive or a code that requires user input, or code that depends on a package that might not be installed on the user's machine

According to "Writing R Extensions" manual:

You can use \dontrun{} for the text that should only be shown, but not run, and \dontshow{} for extra commands for testing that should not be shown to users, but will be run by example()

When you build a package then all code in \dontrun{} closure is visible in help as

## Not run: 

... 

## End(**Not run**)

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.1k users

Browse Categories

...