-
Notifications
You must be signed in to change notification settings - Fork 9
How to add a dataset to this package
Angela Li edited this page Jul 20, 2020
·
9 revisions
- Clone the repository to your computer. Instructions for how to clone the repository into an R project can be found in Happy Git with R. Before doing this, ensure that you have connected RStudio to Git and Github.
- Store the original data from the GeoDa data site as a .shp file (or other raw spatial data format) in
data-raw
. Note that you need all four files, .shp/.dbf/.shx/.prj for a shapefile. You can also use a standalone .gpkg or .geojson if needed. - Create a new cleaning script in
data-raw
calledclean-XXX.R
(XXX should be the name of the raw data file, for consistency). You can copy one of the existing scripts. Make sure to save an sf object in thedata
folder using theusethis::use_data()
function in the script. - Create a new documentation script in the
R
folder called the name of the dataset, ienyc.R
. Follow the same format as one of the existing scripts inR
. Ensure that the dataset name is exactly the same name as the .rda file indata
. You can look up information about the projection/EPSG code included with the dataset at this link. For more on documenting data, check out the R Packages book. - Run
devtools::document()
in the console to write the .Rd files from the roxygen2 headers. These files are stored in theman
folder and should not be edited. - Run
devtools::install()
in the console (or click on "Install and Restart" in the Build panel) to build the package and restart R. Check thatnyc
and?nyc
both work. You added a new dataset to the package! - Run
pkgdown::build_site()
in the console to build the package website from the new documentation. - Add, commit and push your changes.
- (optional) You can edit README.Rmd to mention the dataset you just added. Click "Knit" and it will generate README.md (the reason for this workflow is in case you want to include runnable R code in the README).
For additional reading on how to develop an R package, you can read R Packages or the rOpenSci package development guide.