Contributing to SpatialSablefishAssessment
This is an open source project and we encourage users to make changes and help develop the model further. Any commit to the Github page will trigger the Github actions to check the R package which includes installing it, running unit-tests and building the Gitbook which then will be publicly available. Before commiting to this repository it is recommended to run all these tasks locally.
The Github repository contains a R script called BuildPackage.R
which contains most of the calls that are triggered by the Github actions.
When editing TMB code and recompiling you need to go into the src/
directory and delete any files with the extension .dll
or .o
. You should also do this in the src/TMB
directory. If you don’t delete these libraries sometimes the pkgbuild::compile_dll()
wont recompile the source code with the updated changes. It is best to get into the habit of doing this when dealing with the TMB source code.
Any model that is added, should be able to be unit-tested. For TagIntegrated
model I created a mirror model called TagIntegratedValidate
which has heaps more switches which I didn’t want in the production version, but needed to validate isolated functionality. Although this creates duplicate code bases I still think it is the best approach. When you do this it is recommended that you add a unit-test which checks the production and validation model are the same. This will tell you when you change functionality in one of the models and not the other, thus keeping them compatible and the unit-tests trustworthy.
Adding a new R dependency
All external dependencies are described in the R/SpatialSablefishAssessment-package.R
. I try to import specific functions from packages using the following syntax
#' @importFrom package function
i.e.,
#' @importFrom ggplot2 geom_point
So, if you build a function which uses a function from say dplyr
or ggplot2
that isn’t in SpatialSablefishAssessment-package.R
. You will need to add it there. If you want to use functionality from another library then you will also need to update the DESCRIPTION
file
Tips
You can create a new model by adding a completely new model into the R package by including an new .hpp
file in the src/TMB
directory. To allow the R package access to this new model, modify the file called SpatialSablefishAssessment_TMBExports.cpp
which is also located in the src/TMB
directory. In your new .hpp
file you can use/call any function that defined in the files found at inst/include
directory. These contain selectivity functions and other useful transformation functions that are shared across all models.