View source: R/run_examples_from_package.R
1 | run_examples_from_package(pkgname, local = FALSE)
|
pkgname |
|
local |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (pkgname, local = FALSE)
{
pkg <- sprintf("package:%s", pkgname)
stopifnot(pkg %in% search())
pdfout = sprintf("%s_examples.pdf", pkgname)
msgout = sprintf("%s_examples_message.txt", pkgname)
pdf(pdfout)
on.exit(dev.off(), add = TRUE)
msg <- file(msgout, open = "wt")
sink(msg)
on.exit(sink(NULL), add = TRUE)
sink(msg, type = "message", append = TRUE)
on.exit(sink(NULL, type = "message"), add = TRUE)
op <- options(error = NULL)
on.exit(options(op), add = TRUE)
op1 <- options(example.ask = FALSE)
on.exit(options(op1), add = TRUE)
sapply(ls(grep(pkg, search(), fixed = TRUE, value = TRUE)[[1]]),
example, package = pkgname, character.only = TRUE, local = local)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.