Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/statsrhian/dataexample
Example of storing data in an R package
https://github.com/statsrhian/dataexample
Last synced: 10 days ago
JSON representation
Example of storing data in an R package
- Host: GitHub
- URL: https://github.com/statsrhian/dataexample
- Owner: StatsRhian
- License: gpl-3.0
- Created: 2020-11-09T17:41:28.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2020-11-09T17:54:26.000Z (about 4 years ago)
- Last Synced: 2024-11-15T11:28:41.440Z (2 months ago)
- Language: R
- Size: 334 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# exampleData
Example showing different ways to store data in an R package## R data files
* Have extension `.RData` or `.rda`
* Can store multiple R objects
* Object name is defined when the object is created using `save()`
* Stored in the `data/` folder of the package
* Must be documented. This is done in an R script in the `R/` folder. See `R/data.R` for an example
* Automatically exported (e.g. don't type @export) in the documentation
* Users can access with `data(diamonds, package = "exampleData")`
* Access in functions etc within the package using `dataExample::diamonds`## Other data files
* Can be `.RDS`, `.csv` or other
* RDS files can only store one R object
* Name of object is specified when the object is read in with `readRDS()`
* Stored in `inst/extdata`
* Isn't documented
* Accessed via users and functions with the `system.file()` function. This function only creates the file path. Then have to use appropriate function to read in. E.g. `read_csv(system.file("extdata", "mtcars", package = "dataExample")` or `readRDS(system.file("extdata", "example_data", package = "dataExample")`