Making a data package

rstudio::conf(2022)
Designing the data science classroom

Mine Çetinkaya-Rundel

Goal

  • To make a simple data package, but not to teach all of package development.
  • To use package development best practices, but not to teach all best practices associated with package development (e.g., we won’t cover testing).

Demo: Making a data package

Full demo notes can be found here.

  1. Check if a package name is available with available::available()
  2. Create the package with usethis::create_package()

RStudio Cloud > Module 7 - Data package

  1. Create a data-raw folder for data prep and properly ignore it from package building with usethis::use_data_raw().
    • In the folder, create a folder called weather, put weather.R and weather.csv.
    • Load, clean, and save data in weather.R.
    • Check with devtools::load_all().
  2. Create a documentation file with usethis::use_r("weather").

Demo (continued): Making a data package

  1. Start tracking with version control: usethis::use_git(), then usethis::use_github().
  2. Add a README with usethis::use_readme_rmd(). Write some info, knit, commit, and push.
  3. Update the DESCRIPTION file and usethis::use_gpl3_license().
  4. Create a pkgdown website with usethis::use_pkgdown(), build the site with devtools::build_site().
  5. Publish the site with usethis::use_github_pages(), then use_github_action(name = "pkgdown"). Check the action running on the repo and view your pkgdown website.

Your turn: Add another dataset

RStudio Cloud > Module 7 - Data package

Add a new dataset: cities.csv. Document it to the best of your ability. The data source is Wikipedia.

Demo: Adding a tutorial

  1. Add a tutorial with usethis::use_tutorial("explore-usweather", title = "Exploring weather in US cities").
  2. Edit the tutorial to load this package and confirm that the datasets are accessible to the code chunks.
  3. Open a new project, install the package from GitHub with devtools::install_github("YOUR_GITHUB_USERNAME/usweather"). Confirm that the tutorial is accessible in the Tutorials pane.