Hi Kevin,

It would be more preferable to just use the names of the datasets without having to do `ls()`.

Otherwise, have you tried to load your data into an empty environment per vignette and
then do `ls()` on that environment?

For example,

```{r, echo=FALSE}
vig_data1 <- new.env(parent = emptyenv())
data(..., package = "RPointCloud", envir = vig_data1)
ls(envir = vig_data1)
```

and show the user a non-evaluated chunk

```{r,eval=FALSE}
ls()
```

Best regards,
Marcel

On 2/17/26 1:47 PM, Ben Bolker wrote:
* External Sender - Proceed Cautiously with Links and Attachments. *

      It might run afoul of the "don't use attach()" rule, but attach()
seems like a good solution for this? e.g

attach(mydata)
ls("mydata")

... do stuff ...

detach(mydata)
?  This assumes you don't modify the object ...

On Tue, Feb 17, 2026 at 1:41 PM Kevin R. Coombes
<[email protected]> wrote:
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

______________________________________________
[email protected] mailing list
https://urldefense.com/v3/__https://stat.ethz.ch/mailman/listinfo/r-package-devel__;!!LRXxDv2l!TCoohdCCt53OwwimPx9i6UhVDPy6NpUMzn-z9-F1sE_GnHi5m8hgN1THdXv-vWXA0ooLFOUPO2-QzRgao6mHYQ$
______________________________________________
[email protected] mailing list
https://urldefense.com/v3/__https://stat.ethz.ch/mailman/listinfo/r-package-devel__;!!LRXxDv2l!TCoohdCCt53OwwimPx9i6UhVDPy6NpUMzn-z9-F1sE_GnHi5m8hgN1THdXv-vWXA0ooLFOUPO2-QzRgao6mHYQ$
--

____

*Marcel Ramos, MPH*
Sr. Data Scientist

CUNY Graduate School of Public Health & Health Policy
55 W. 125th Street, Room 621| New York, NY 10027
[email protected] <mailto:[email protected]> | (646) 364-9585
CUNY Logo <https://sph.cuny.edu>
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

Reply via email to