I have a package whose internal functions I want to load in the global environment. The only way I can think of is to do it manually, i.e.
f <- packageName:::someInternalFunction
For all internal functions. I'm guessing there's an easier way to do it, but how? Thanks in advance.
You could do the following:
library(pacman)
pack.name <- "qdap"
hidden <- setdiff(p_funs(pack.name, TRUE), p_funs(pack.name))
invisible(lapply(hidden, function(x) {
a <- strtrim(x, 1) == "%"
b <- substring(x, nchar(x)) == "%"
if (a && b) {
x2 <- paste0("`", x, "`")
} else {
x2 <- x
}
assign(x, eval(parse(text=paste0(pack.name, ":::", x2))),
envir = .GlobalEnv)
}))
Use package pacman
as an example:
attach(loadNamespace("pacman"), name = "pacman_all")
Now all its unexported functions are available. You can see the attached "pacman_all" with search()
.
To revert, run detach("pacman_all")
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With