Project setup and git workflow
Setup Development Environment
- install git
- clone this repository
- open the rstudio project
- install dependencies with
renv::restore()
Project Setup Troubleshooting
If you’re not using Rstudio: start R with the root folder of the project as working directory. renv should be loaded automatically and you should see a message like Project '...' loaded. [renv 1.1.5] and you should be able to use renv::restore(). If renv is not automatically loaded use source("renv/activate.R") to load it.
Project Structure
Reusable functions, methods, etc. will be available as an r-package (built from this repository), that can be tested, built, installed, and distributed. Bespoke code for the simulation study will be included in the directory scripts.
Contribute Code / git workflow
To contribute code:
- switch to the main branch
git checkout main - make sure you are on the latest version of the main branch
git pull main - create a new branch from there
git checkout -b <new_branch_name>(replacewith the name of your branch) - write your code
- Run
renv::status()to check if any pacakges need to be installed, updated or added to renv. If necessary userenv::snapshotto add packages you installed to renv orrenv::restoreif you are missing pacakges others have added. - run
devtools::document()to generate documentation and updateDESCRIPTIONandNAMESPACE - run
devtools::test()anddevtools::check(), if there are any errors, fix them and iterate from step 5. if all errors are taken care of continue to 8. - commit your code to git through the Rstudio userinterface or with
git add .followed bygit commit -m "<one-line description of the changes>" - push your code to github with
git push -u origin <new_branch_name>for the first time and justgit pushafterwards - to merge code into the main branch, open a pull request on github. Navigate to your branch use the “Compare & pull request” button.
Coding Style
Please approximately keep to the tidyverse style guide to keep the code easily readable.
Roxygen documentation
Documentation and package metadata are automatically generated with the roxygen2 package. You can add the roxygen tags in r-studio with Code > Insert Roxygen Skeleton. When using functions from other packages, also insert an @importFrom <package> <function1> <function2> ... tag. (See R/utility_functions.R for an example.)
Please also add examples to your function. When adding examples, please ensure that they run without error, since examples are checked when building the package.