简体   繁体   中英

How to load .Rdata from an R package?

I am developing an R package. In the package, I stored some .Rdata file from the simulation results. Now I would like to load/use those .Rdata in the rmarkdown so that I can write vignettes. I can load those data from my computer. But my question is how do I load data from my own package directory? Because in the future some users of the package may need to follow the same code from the vignette and reproduce the results or plots.

Assuming you used devtools::use_data() , you can use library(YOUR_PACKAGE); data("dataset") library(YOUR_PACKAGE); data("dataset") in your vignette, where "dataset" is the data you're talking about. Running devtools::load_all() will make the data available to you as you are writing the vignette.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM