-
Notifications
You must be signed in to change notification settings - Fork 0
Including data
Katie Paulson edited this page Aug 6, 2020
·
2 revisions
It can be really useful to include example data in packages. It allows users to immediately have a dataset that is formatted to work with the package functions. It can also be a good way to distribute topic specific data. For example the UN WPP results.
Steps:
- Use
usethis::use_data_raw(name)
to create a.R
file in thedata-raw
directory. - Add code to this file to generate a data file. At the end of this script, use
usethis::use_data
to save a.rda
file to thedata
directory. - Create a file
R/data.R
. Here, you can use Roxygen syntax to create documentation on the dataset. - Then, data can be loaded into your workspace with
data()
.
See Hadley's R packages book for more details.