Skip to content

Instantly share code, notes, and snippets.

@smbache
Created April 2, 2015 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smbache/8c51ec14420bd185cd3a to your computer and use it in GitHub Desktop.
Save smbache/8c51ec14420bd185cd3a to your computer and use it in GitHub Desktop.
Example of a function to copy functions from a package.
# a few utility funcs, might as well take them from `import`
import::here(symbol_list, symbol_as_character, .from = import)
copy_from <- function(.from, ...)
{
symbols <- symbol_list(...)
parent <- parent.frame()
from <- symbol_as_character(substitute(.from))
for (s in seq_along(symbols)) {
fn <- get(symbols[s], envir = asNamespace(from), inherits = TRUE)
assign(names(symbols)[s],
eval.parent(call("function", formals(fn), body(fn))),
parent)
}
invisible(NULL)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment