Skip to content
Prev 12090 / 12125 Next

[R-pkg-devel] Carry over in package with multiple vignettes

Hi,

I have an R package (RPointCloud) that contains three vignettes. Each 
vignette starts by loading a different example dataset, and then calls 
"ls" to show the reader what objects were loaded. It is abundantly clear 
that the vignettes are all produced in the same R process. Thus, the 
"ls" in the later vignettes includes a list of all objects created 
during earlier vignettes. Since each vignette is really intended to be 
standalone, these lists are misleading.

In an early submission of the package, I included a command at the end 
of the form "rm(list = ls())", which I removed after objections from a 
CRAN reviewer that this process could/would remove things that a user 
already had in their workspace before they started running the vignette 
themselves. So, I took those commands out.

What is the best way to ensure that objects are not carried over from 
one vignette to another? I am thinking about the following:

# at the top of each vignette:
origobj <- ls()

# at the bottom of each vignette
currobj <- ls()
ourobj <- currobj[!(currobj %in% origobj)]
rm(list = ourobj

Will this procedure pass the CRAN review? Is there a better way to 
accomplish this goal?

Thanks,
 ? ?Kevin