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

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


require(stats); require(graphics)

#examples from glm:

**## Not run:** 


with(anorexia, {

    anorex.1 <- glm(Postwt ~ Prewt + Treat + offset(Prewt),

                    family = gaussian)



## End(**Not run**)

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

1 Answer

0 votes
edited 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**)

Browse Categories