mizer is an R package for dynamic multi-species size-spectrum modelling of fish communities.
devtools::load_all() # Load package for development
devtools::document() # Regenerate NAMESPACE and man/ pages from roxygen2
devtools::test() # Run all tests
devtools::check() # Full R CMD check
lintr::lint_package() # Lint the package
# Run a single test file
testthat::test_file("tests/testthat/test-filename.R")
# After editing C++ source
devtools::clean_dll(); devtools::load_all()MizerParams (S4) — central object passed to nearly all functions. Modified via setter functions that return new copies: setFishing(params, ...), etc.
MizerSim (S4) — stores simulation output: arrays n (time × species × size), n_pp, n_other, effort, and the MizerParams used.
ArraySpeciesBySize / ArraySpeciesByTime (S3) — wrap 2D arrays with metadata. When assigning back to S4 slots, use slot[] <- value (not slot <- value) to strip the class.
Customisable rate functions: users replace rate functions by storing a custom function name in params@rates_funcs. Dispatch via get(params@rates_funcs$FunctionName)(params, ...).
Auto-generated files — never edit NAMESPACE, man/, RcppExports.R, or RcppExports.cpp directly.
- Indentation: 4 spaces
- Naming: camelCase or snake_case for functions/variables; PascalCase for classes
- Language: British English (en-GB) — "colour", "behaviour", "modelling"
- Use
expect_doppelganger()(vdiffr) for plot tests - Use snapshot tests for complex outputs
- Run
devtools::document()after adding or changing exports - Run
devtools::load_all()before running tests - After modifying the
MizerParamsorMizerSimclass (new/removed slots, changes to@rates_funcs, etc.), follow the steps in.claude/skills/upgrade-mizer-data.md. Claude Code users can invoke this as/upgrade-mizer-data.
- After adding a new file under
R/, add it to theCollate:field inDESCRIPTION(roxygen2 does not manage this automatically in this package). - Update
NEWS.mdwhen adding features or fixing bugs.