variable scope across package vignettes

If i have two vignettes in an R package that use the same data source. Is there a way to load in the data just once and have it accessible to both vignettes.

Assume the dataset is large and takes significant time to load and can't be included as lazydata in the package

for example. I have the following r chunk in both vignettes


{r , echo = F}
dat <- readRDS(here::here("data-raw/bigData.rds")) 


But it takes a long time to read in the data so i want to minimize this time by doing it just once

I don't think that's possible. As far as I can remember each vignette runs in a separate process.

On the other hand, the RDS reader in R is pretty slow, so maybe you can store the data in a different format, that is faster to read.

1 Like