example
Run the Examples Section from the Online Help

Description

Runs the examples section from the online help and shows the results.

Usage

example(topic, package = NULL, lib.loc = NULL, character.only = FALSE, 
    give.lines = FALSE, local = FALSE, echo = TRUE,
    verbose = getOption("verbose"), setRNG = FALSE,
    ask = getOption("example.ask"),
    prompt.prefix = abbreviate(topic, 6),
    run.dontrun = FALSE,
    run.donttest = interactive())

Arguments

topic a name or a character string containing the name of the help topic for which to run the examples.
package a name or a character string specifying the package where topic is searched. If NULL, all loaded packages in the search list are used for topic searching.
lib.loc a character vector containing the names of library directories. If NULL, the .libPaths() is used.
give.lines a logical value. If TRUE, the text of the examples is returned as a character vector. If FALSE (the default), the examples are evaluated.
local This argument is not yet implemented. a logical value. If TRUE, the examples are evaluated in the environment local to the example function. If FALSE (the default), the examples are evaluated in the global environment.
echo a logical value. If TRUE (the default), each expression of the example is printed, along with a prompt, before it is evaluated. If FALSE, the expressions are not printed.
verbose This argument is not yet implemented. a logical value. If TRUE, additional diagnostics are printed as the function parses and evaluates the examples. The default is the value of system option "verbose".
setRNG a logical value or a TIBCO Enterprise Runtime for R expression used to set the random number generator. If TRUE, the random number generator is set as if setRNG = { RNGkind("default", "default"); set.seed(1) }. The random number generator is restored to its previous state when the example function exits. The default is FALSE.
ask This argument is not yet implemented. a logical value or the character string "default".
  • If TRUE, devAskNewPage is called before any graphics output to ask the user to acknowledge each new page.
  • If "default", ask is set to TRUE if echo is TRUE, and if the current graphics device is interactive.
The default is the value of the system option "example.ask".
prompt.prefix This argument is not yet implemented. a character string to use as a prefix of each line of examples. By default, a six character abbreviation of topic is used as the prefix.
character.only a logical flag. If TRUE, the topic must be a character string. The default is FALSE.
run.dontrun a logical flag. If FALSE, the default, comment out sections of the example code marked with the \dontrun macro. If TRUE, include the code marked \dontrun in the example.
run.donttest a logical flag. This is applied to to the \donttest sections of the examples in the same way that run.dontrun is applied to the the \dontrun sections.
Value
See Also
help, source, options, RNGkind, set.seed, abbreviate
Examples
## Not run: 
example(objects)
example(objects, character.only = TRUE) # objects is not a character string, return error.
example("objects")
example(objects, echo = FALSE)
example(objects, package = "stats")
example(system, echo = FALSE)
example(system, echo = TRUE)
example(objects, prompt.prefix = "result")
example(objects, give.lines = TRUE)

x1<-example(runif, setRNG = TRUE); x2<-example(runif, setRNG = TRUE); identical(x1,x2) #TRUE x1<-example(runif, setRNG = FALSE); x2<-example(runif, setRNG = FALSE); identical(x1,x2) #FALSE x1<-example(runif, setRNG = set.seed(1)); x2<-example(runif, setRNG = set.seed(2)); identical(x1,x2) #FALSE ## End(Not run)

Package utils version 6.0.0-69
Package Index