Created
April 2, 2015 19:28
-
-
Save smbache/8c51ec14420bd185cd3a to your computer and use it in GitHub Desktop.
Example of a function to copy functions from a package.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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