snippet {fastR2} | R Documentation |
Display or execute a snippet of R code
Description
This command will display and/or execute small snippets of R code from the book Foundations and Applications of Statistics: An Introduction Using R.
Usage
snippet(
name,
eval = TRUE,
execute = eval,
view = !execute,
echo = TRUE,
ask = getOption("demo.ask"),
verbose = getOption("verbose"),
lib.loc = NULL,
character.only = FALSE,
regex = NULL,
max.files = 10L
)
Arguments
name |
name of snippet |
eval |
a logical. An alias for 'execute'. |
execute |
a logical. If |
view |
a logical. If |
echo |
a logical. If |
ask |
a logical (or "default") indicating if
|
verbose |
a logical. If |
lib.loc |
character vector of directory names of R libraries, or NULL. The default value of NULL corresponds to all libraries currently known. |
character.only |
logical. If |
regex |
ignored. Retained for backwards compatibility. |
max.files |
an integer limiting the number of files retrieved. |
Details
snippet
works much like demo
, but the interface is
simplified. Partial matching is used to select snippets, so any unique
prefix is sufficient to specify a snippet. Sequenced snippets (identified by
trailing 2-digit numbers) will be executed in sequence if a unique prefix to
the non-numeric portion is given. To run just one of a sequence of snippets,
provide the full snippet name. See the examples.
Author(s)
Randall Pruim
See Also
Examples
snippet("normal01")
# prefix works
snippet("normal")
# this prefix is ambiguous
snippet("norm")
# sequence of "histogram" snippets
snippet("hist", eval = FALSE, echo = TRUE, view = FALSE)
# just one of the "histogram" snippets
snippet("histogram04", eval = FALSE, echo = TRUE, view = FALSE)
# Prefix too short, but a helpful message is displayed
snippet("h", eval = FALSE, echo = TRUE, view = FALSE)