-
Notifications
You must be signed in to change notification settings - Fork 0
Development
Make sure you have a recent version of R (>= 4.0.0) installed. Though not required, RStudio is recommended as an IDE, as it has good support for R package development and Shiny.
-
Clone this repository
- Either with
git clone https://github.com/SAFEHR-data/omopcat.git
- Or by creating a new project in RStudio from version control
- Either with
-
You will also need some packages installed on your OS for the next stage to work. If you don't perform this step the next stage will tell you (gradually) which packages to install, but it will be quicker if you install them ahead of time. The packages you need are as follows:
- For Ubuntu/Debian:
libcurl4-openssl-dev libfontconfig1-dev libharfbuzz-dev libfribidi-dev libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev libxml2-dev
- For Ubuntu/Debian:
-
Open navigate to
preprocessing
directory and open theomopcat.preprocesssing.Rproj
file in Rstudio -
Install
{renv}
and restore the project library by running the following from an R console in the project directory:install.packages("renv") renv::restore()
-
Configure the "low-frequency statistics masking" feature, by defining a threshold and a replacement value (values below the threshold will be replaced, in the summary statistics), as environment variables.
When running the app locally in development mode, these variables need to be defined in a
.Renviron
file. To add and edit this file locally, runusethis::edit_r_environ("project")
and paste the following lines in
LOW_FREQUENCY_THRESHOLD=5 LOW_FREQUENCY_REPLACEMENT=2.5
-
To preview the app locally, run the following from an R console within the project directory:
golem::run_dev()
The dev/02_dev.R
script contains a few helper functions to get you started.
We use the pre-commit framework to run automated checks before committing code. To set this up locally, follow the steps below.
- Make sure you have
pre-commit
installed on your machine, installation instructions here - Install the
precommit
R package from within R withinstall.packages("precommit")
- Initialise
precommit
in your local repo, from within Rprecommit::use_precommit(config_source = "./.pre-commit-config.yaml")
For more information on the available hooks for R, see the precommit
documentation.
Make sure to regularly run renv::status(dev = TRUE)
to check if your local library and the lockfile
are up to date.
When adding a new dependency, install it in the renv
library with
renv::install("package_name")
and then use it in your code as usual.
renv
will pick up the new package if it's installed and used in the project.
To update the lockfile, run
renv::snapshot(dev = TRUE)
The dev = TRUE
argument ensures that development dependencies (e.g. those recorded under
Suggests
in the DESCRIPTION
file) are also included in the lockfile.
We'll mainly follow the tidyverse style guide.
The {styler}
package can be used to automatically format R code to this style,
by regularly running
styler::style_pkg()
within the project directory.
It's also recommended to install {lintr}
and regularly run
lintr::lint_package()
(or have it run automatically in your IDE).