I have a package that generates some functions when you call an initialize
function. I create these functions in the parent.frame
of initialize()
, which I guess is the global environment. I want to emulate the normal package behavior that allows you to directly call a function from a package after loading it, but without having to see those functions when you list your workspace contents using ls()
. For example, doing
library(ggplot2)
ls()
doesn't return geom_line
, geom_point
, etc., but you don't have to use ::
to call those functions. They are exposed to the user but do not live in the global environment.
Is there a clever way for me to do the same thing for functions generated by the call to initialize
, e.g. by defining environments or namespaces in zzz.r
and the onLoad
or onAttach
hooks? I thought of trying to set the function environments to the package namespace, but it seems that you cannot modify the package namespace after it is loaded.
EDIT the package I'm working on is here: https://github.com/mkoohafkan/arcpyr. The arcpy.initialize
function connects to Python using PythonInR, imports the arcpy
package, and then creates interfaces for a list of functions. I'll try to create a simplified dummy package later today.