How Carob works
Carob is not a static database of manually edited spreadsheets. Instead, it is an open-source collection of R scripts that download published agricultural research datasets from their original repositories, standardize them to a common vocabulary and set of units, and compile them into unified data files.
Because every transformation is recorded in code, mistakes can be traced and fixed, new variables can be added as the standard evolves, and anyone can reproduce the entire compilation from the original sources.
The main components
Carob brings together four open-source repositories:
carob: the main repository of dataset-processing scripts, organized by thematic group under
scripts/<group>/.carobiner: the R package that drives the workflow — drafting scripts (
draft), downloading raw data (get_data), recording metadata (get_metadata), checking and writing standardized outputs (write_files), and compiling datasets (run_carob,make_carob).terminag: the controlled vocabulary defining accepted variable names, data types, units, valid ranges, and categorical values (checked via the vocal package).
yuri: the helper package that resolves persistent identifiers (DOIs and handles) and downloads files from data repositories such as Dataverse and Zenodo.
From raw dataset to compiled data
Each published dataset is processed by a single R script named after its normalized URI (for example, doi:10.21421/D2/STACVA becomes doi_10.21421_D2_STACVA.R). Scripts are placed in a thematic group folder under scripts/ — such as agronomy, varieties_maize, varieties_wheat, soil_samples, survey, pest_disease, or weather.
When a script runs (via carobiner::run_carob() or carobiner::make_carob()), it follows four steps:
Download (Extract):
carobiner::get_data(uri, path, group)downloads the raw files from the source repository intodata/raw/<group>/<dataset_id>/. Files are cached locally so subsequent runs do not re-download them.Standardize (Transform): the script reads the raw files, reshapes the data into a tidy
data.framed, renames columns and converts units to match terminag, fixes georeferences and spelling inconsistencies, and fills in dataset-level metadata withcarobiner::get_metadata(). When a dataset contains repeated measurements over time, weather records, or variable-level methods, the script writes additional linked tables alongsided— see Multiple tables.Validate and save:
carobiner::write_files()checks the standardized tables against the terminag vocabulary and required-variable rules, reports any warnings or out-of-bounds values, and saves the standardized CSV files underdata/clean/<group>/.Compile (Load):
carobiner::make_carob()(orbuild_carob.bat/build_carob.sh) combines all clean datasets in each group into the compiled CSV and RDS files indata/compiled/(see Compile and Download).
Only the scripts are tracked in Git. The data/raw/, data/clean/, and data/compiled/ folders are generated locally on your computer and are ignored by Git.
How contributions are integrated
Contributions follow a standard GitHub pull-request workflow:
Fork and clone the carob repository (see Git).
Create a branch for a single dataset and either check and complete an existing draft in
scripts/_todo/(see the to-do list and working with drafts in _todo) or draft a new script withcarobiner::draft(uri, path, group)(see the example and guidelines).Run and verify the script locally, resolving errors and documenting any remaining issues in comments at the top of the file.
Open a pull request for that single script. A maintainer reviews the code and comments, requests any refinements, and merges the script into
carob-data/carob.Once merged, the dataset is automatically included in the next compiled Carob release.