ialm
ialm

Reputation: 8717

Creating a data.frame for R package

I am making an R package, and there is a need to keep track of files that were opened using the functions in the package.

What is the recommended procedure for creating R objects (in this case, a data.frame) upon loading the package in a way that is (sufficiently) hidden from the user? I do not want the user to manually edit the data.frame.

One idea I had was to create a data.frame in the options settings inside of an .onLoad call (similar to what Hadley does in his devtools package here), but the list of opened files is not really a configurable "option" in my package. Is there another way?

Upvotes: 3

Views: 161

Answers (1)

Alex A.
Alex A.

Reputation: 5586

When you create an R package, unless you're exporting all objects, you have to list which objects are exported in the NAMESPACE file. If you need to maintain a data frame within your package but you don't want it made available to the user, you can choose not to export it by excluding it from the list.

Upvotes: 1

Related Questions