print and execute functions in a package namespace
But I need to work with the names of the figure functions instead, something
like
figlist <- paste0("fig", 1:3)
Are the functions exported or internal?
# Use for internal functions
pkg <- asNamespace("mypackage")
# Use for exported functions:
pkg <- "package:mypackage"
# Find functions matching a pattern:
figfuns <- grep("fun.*", ls(pkg), value = TRUE)
# Convert names into functions
funs <- lapply(fig, get, envir = pkg)
onefig2 <- function(fig) {
cat("Figure:", fig, "\n")
print(body(fig))
fig()
}
lapply(funs, onefig2)
Hadley
RStudio / Rice University http://had.co.nz/