I'm writing documentation for my R package using vignettes (which will be embedded in a pkgdown website.
My question is : if I create an R object in a chunk within a first "aa" vignette.
myobject <- mypkg::myfct()
How to reuse this object in a second vignette called "bb"?
verif <- myobject[myfilters,]
I get this error : myobject not found
This doesn't seem like a good idea. You can save this data in an internal RDA file, and load it in the second vignette. See Chapter 14 External data, R Pakcages .
So you'd have to:
data_raw
folder, and have a script that creates this object, then saves it. This is facilitated by usethis::use_data_raw
, with like "myfct_example".data_raw
ensure that internal = TRUE
; This will save the object in R/sysdata.rda
, instead of data/myfct_example
(if you call that object that).data_raw/myfct_example
script every time you change myfct_example
, so the new version get stored in R/sysdata.rda
.mypkg:::myfct_example
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.