hadley / r-pkgs

Building R packages
https://r-pkgs.org
Other
866 stars 631 forks source link

Clarify where to store inputs for internal data workflow code #1047

Open kaijagahm opened 6 months ago

kaijagahm commented 6 months ago

I suggest clarifying where to store objects that get turned into internal data via workflow scripts as described in Internal Data.

Example: one of my package functions needs to refer to an internal shapefile (in order to perform a standard spatial filtering procedure). Following the instructions in the Internal Data section, I know that I should create workflow code that looks something like this:

shapefile <- sf::st_read("path/to/my/shapefile.kml")
usethis::use_data(shapefile, internal = TRUE)

The chapter is quite clear that this workflow code should be stored in data-raw/, but unless I'm missing something, there is no mention of where shapefile.kml should live. In other words, if you're creating an internal data object from some existing file, where should that source file go?

@jonthegeek suggests that it should also go in data-raw/ and gives the example of babynames. (Slack thread). Seems reasonable to me. So then we would have:

shapefile <- sf::st_read("data-raw/shapefile.kml")
usethis::use_data(shapefile, internal = TRUE)

Probably overkill, but "I assign the copyright of this contribution to Hadley Wickham" as per the contributing guidelines.