Created
February 27, 2018 12:42
-
-
Save cosi1/64a11cc5ba1a680d84b8796d11eec289 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # Imports a namespace under an alias | |
| # (equivalent of Python's `import ... as ...`) | |
| importAs = function(namespace, alias) { | |
| namespace::registerNamespace(name = alias, env = asNamespace(namespace)) | |
| } | |
| # Imports function(s) from a namespace (including unexported functions) | |
| # to the global namespace | |
| # (equivalent of Python's `import ... from ...`) | |
| importFrom = function(namespace, functions) { | |
| for (fun in functions) { | |
| assign( | |
| fun, | |
| getFromNamespace(fun, ns = asNamespace(namespace)), | |
| env = parent.frame() | |
| ) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment