Notes for developers
Source:DEVELOPERS.md
System requirements
- just
- R (version 4.0 or higher)
- air for code formatting
- Quarto CLI and the quarto R package
Local development environment
The just command provides a list of available recipes, most of them are also available as shortcuts in Positron or RStudio:
Testing
Unit tests are implemented with teststhat in tests/testthat (run just test-unit). To keep unit tests fast but still test the full pipeline (download and tidy) integration tests are in tests/integration.R (run just test-integration). There may be a way to also add integration tests to testthat without running them every time (possible using environment variables), but I haven’t explored that yet. The just recipe just test runs both tests.
Documentation
Documentation is built with pkgdown.
Development workflow
- Install package locally:
just build(orpak::local_install()) - Make changes to code
- Run
just fixto format - Run
just documentif you changed roxygen2 docs - Run
just testto verify tests pass - For schema updates:
just update-schemas - Run
just checkbefore submitting a PR - Update docs with
just docsif needed
Configuration files
Data sources and transformations are defined in inst/config/ as YAML files:
Raw data sources (archives, URLs, periods): - raw_annual_data_config.yml: Annual datasets - raw_monthly_data_config.yml: Monthly datasets - raw_metadata_config.yml: Metadata
Tidy transformations (filters, derivations, output columns): - tidy_annual_data_config.yml - tidy_monthly_data_config.yml - tidy_metadata_config.yml
Schemas (auto-generated column tracking): - Run just update-schemas after modifying raw_annual_data_config.yml - Schemas saved to inst/schemas/annual_main_schemas.csv
Dev utilities
Internal functions in R/dev-utils.R help explore archive contents before exposing new data through the package: - list_available_archives(): See all archives and periods - list_archive_files("annual_main", "2024-25"): List CSV files in an archive - read_archive_file("annual_main", "2024-25", "main"): Read specific files - compare_schemas("main"): Compare column changes across periods
Access via devtools::load_all() or nhstt:::function_name().