A cut back version of example() for obtaining the text used in examples on help pages without running those examples. The function is intended to help write markdown/Sweave documents.
GetExampleText(topic, package = NULL, lib.loc = NULL, character.only = FALSE, outFile="")
a vector of character strings each element being one line of the examples from the corresponding help topic.
name or literal character string: the online help topic the examples of which should be run.
a character vector giving the package names to look into for the topic, or NULL (the default), when all packages on the search path are used.
a character vector of directory names of R libraries, or NULL. The default value of NULL corresponds to all libraries currently known. If the default is used, the loaded packages are searched before the libraries.
a logical indicating whether topic can be assumed to be a character string.
an optional filename to save the results into. The default is to use a temporary file.
The work of Martin Maechler and others got tampered with by A. Jonathan R. Godfrey
The example() code was hacked back to form this utility function. It is probably a little heavy for what is needed but it works sufficiently at the time of creation.
You may wish to compare this with example
cat(paste(GetExampleText(mean), collapse="\n"))
Run the code above in your browser using DataLab