This repository contains R and R Markdown scripts used by the IWC Secretariat Statistics and Modelling Department to produce recurring statistical reports, tables, appendices and circular communications.
Many of these products are prepared every one or two years. The aim of the repository is to retain the code used to produce them, make recurring reporting more reproducible, and reduce the amount of manual processing required when reports are updated.
RMD_statistics_reporting/
├── catches and infractions/
├── circulars/
├── inputs/
├── O paper catches/
├── outputs/
└── README.md
Contains scripts used to prepare catch and infractions summaries and reports, including annual and multi-year catch summaries, infractions tables and appendices.
See catches and infractions/README.md.
Contains R Markdown files and Word reference documents used to generate recurring IWC Circular Communications.
See circulars/README.md.
Contains the mock, synthetic and supporting input files required to test and run the reporting workflows.
See inputs/README.md.
Contains the R Markdown workflow used to prepare catch reports for Scientific Committee O papers.
See O paper catches/README.md.
Contains reports and tables generated by the scripts.
See outputs/README.md.
The workflows are written mainly in R and R Markdown.
Packages used across the repository include:
readxl
dplyr
tidyverse
plyr
reshape2
flextable
officer
magrittr
lubridate
stringrIndividual scripts may require only a subset of these packages.
The scripts generally use relative paths so that the repository can be moved or cloned without rewriting local file paths.
For example:
../inputs/NationsMembership.xlsx
../inputs/catches-postMoratorium-test.xlsx
../outputs/The repository folder structure should therefore be retained.
User-specific absolute paths should be avoided.
The repository contains mock or synthetic datasets that reproduce the structure expected by the reporting scripts.
These allow the workflows to be:
- tested without access to operational data;
- checked after changes to the scripts;
- used as examples of the expected input structure;
- tested after changes to R or package versions.
Operational, confidential or personal data should not be committed to a public repository.
Many reports contain parameters in the R Markdown YAML header, for example:
params:
first_year: 2024
last_year: 2025Before generating a report:
- check the relevant folder README;
- ensure the required input files are available in
inputs/; - check the year or reporting-period parameters;
- knit the
.Rmdfile or run the relevant.Rscript; - review the generated Word document;
- check any placeholders, dates, reference numbers, signatories and links before circulation.
Where possible, data manipulation, table construction, captions and document generation should remain within the R/R Markdown workflow rather than being edited manually after the output has been created.
This repository is intended to provide a reproducible record of the workflows used to prepare recurring IWC statistical reporting products.