- In your package project, run
usethis::use_data_raw("demo-data")to set up adata-raw/folder with ademo-data.Rfile inside. - Write a script in
demo-data.Rto produce the data object (e.g.demo_df). - Insert and run the line
usethis::use_data(demo_df)indemo-data.R, which will save the data object to adata/demo_df.rdafile. - Run
usethis::use_r("demo-data")to create a correspondingR/demo-data.Rfile where you can document the data. - In
R/demo-data.R, quote the name of the data object (i.e."demo_df") and put {roxygen2} code above it (probably at least@title,@descriptionand maybe@format, which might contain a\describe{}block to explain the content of your object, itself containing an\item{}to describe each column if it's a data.frame). - Run
devtools::document()to generate theman/pages for the data. - Run
devtools::load_all()to reload your package and makedemo_dfavailable in your session. - Once pushed, users can attach the package and access
demo_dfby name, or access it withpackage::demo_dfnamespacing.
Last active
June 5, 2024 16:03
-
-
Save matt-dray/e3877159c6a8f8a65ca35b5229035524 to your computer and use it in GitHub Desktop.
Steps to create an exported dataset in an R package with {usethis}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment