Datamonger for R
Reproducible Retrieval and Decoding of Public Research Data
Datamonger brings public research datasets into R. It downloads and verifies the data, returns data frames or sparse matrices, and keeps track of dataset versions, sources, and citations. Downloaded files are cached for reuse, including when you work offline.
Installation
Datamonger is under development and is not yet on CRAN. Install the development version from GitHub with pak:
# install.packages("pak")
pak::
Installation requires Rust, Cargo, and xz. On Windows, install the Rtools build for your R installation. Run rustup target add x86_64-pc-windows-gnu for x64 R or rustup target add aarch64-pc-windows-gnullvm for ARM64 R.
Getting started
Fetch the Iris dataset from the UCI Machine Learning Repository:
flowers <-
The reference "uci:iris" combines the source and dataset name. You can also write fetch_data("iris", source = "uci"). The first call downloads the data; later calls verify and reuse the cached files.
Iris is returned as a data frame. Sparse datasets, such as those from LIBSVM, return a sparse feature matrix and a response vector:
heart <-
Datasets with predefined splits keep them separate. Access each split by name, such as data[["train"]] or data[["test"]].
Find datasets
Browse the available datasets and inspect their metadata before downloading:
info <-
info
info$license
info$provenance
The package includes a dataset catalog, so these calls do not need to download the data. Metadata includes the source, license, and known preprocessing steps. Fetching a dataset does not apply the recorded preprocessing again.
To get citation text for your analysis:
cite_data() includes upstream citation instructions and selects recommended references when they are recorded. Use include_all = TRUE to see every reference.
Reproducible analyses
Add a version to a dataset reference to select it explicitly. Request metadata alongside the data to record what you used:
registry <-
result <-
flowers <- result$data
result$info
The metadata records the dataset version, catalog release, and checksums used to verify the data. Save the registry selector with your analysis to reuse the same catalog in a later session:
provenance <-
flowers <-
Caching and offline use
After downloading a dataset, use it without network access:
flowers <-
An offline fetch raises an error if a required file is missing from the cache. Use cache_info() to inspect cached files and cache_clean() to remove them. To use a separate cache for a project, pass cache_dir:
flowers <-
Learn more
See the getting started vignette for more examples, or use ?fetch_data, ?data_info, and ?cite_data in R. The project website introduces the other Datamonger clients, and CONTRIBUTING.md covers local development.
License
Datamonger is licensed under the MIT license. Datasets retain their own licenses and terms; check each dataset's metadata before using it.
