- In your package project, run
usethis::use_data_raw("demo-data")
to set up adata-raw/
folder with ademo-data.R
file inside. - Write a script in
demo-data.R
to 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.rda
file. - Run
usethis::use_r("demo-data")
to create a correspondingR/demo-data.R
file 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
,@description
and 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_df
available in your session. - Once pushed, users can attach the package and access
demo_df
by name, or access it withpackage::demo_df
namespacing.
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