In a long-term project that uses R, I have a set of about 50 functions that I've defined which I use all the time, and another 10 or 15 that I use once in a while. Most of these are not functions I use directly; they're helper functions I've used to define the ones I use directly. When I load data objects from R data files, I don't always remember what I named the objects, so I execute ls()
to see what I loaded. If I've loaded my source doe files, though, I have to visually sift through the output to fine the data objects, which is obviously inconvenient.
So I wrapped the functions into an R package. If I just load the package, then everything is fine. I can use the functions, but ls()
only shows me the data objects.
However, I keep adding new functions. And I find that remaking the package is not entirely trivial, so I end up loading my functions from the source files anyway much of the time--until I get around to remaking the package.
I can of course automate the package construction process more than I have, or split my new functions out in separate source files. I could also split the functions into different packages--maybe that would help. I think I could make the helper functions available only via a closure over the ones I call directly--I haven't tried that--but then I can't use the helpers directly if I want to do so, and it seems like overkill if there's a simpler way. And that's what I'm wondering: whether there's an easy trick that I've missed--a way to make functions available for use, but make it easy to show me what data objects I have without listing the functions. If not, OK, but I thought it would be worth asking. Thanks.
These questions: hiding personal functions in r and remove all variables except functions provide very useful answers. What is the absolutely easiest way to accomplish what's described above?