Feature request: Load package functions into an existing environment even if it is not attached to the search path
Closed this issue · 3 comments
I normally source my util functions into a new environment and call the util functions by specifying the environment variable name to avoid flooding my global environment with util functions:
util <- new.env()
source("util.R", local=util)
util$hello() # call the helper function
If the util code is stable I want to create a package.
To avoid changing all calls of the util functions I would like to use your package to load all package functions into a new enviornment:
util <- new.env()
import::from(util, .into = util) # this does not work of course since "into" requires a string, not an environment
Would it be possible to add such a functionality?
PS: See also this question at SO: https://stackoverflow.com/questions/40075236/load-library-into-existing-environment-equivalent-to-local-parameter-of-sour
I suppose the .into
could be examined, and if this is an environment, then importing could target this instead...
or by introducing a new parameter like .into.env
to make the difference more clear (but overlading .into
is also OK)...