Skip to content
Matchy edited this page Sep 20, 2024 · 2 revisions

Developer Guide

Developer environment setup

It is recommended to use renv to easily manage the package dependency. To install renv, run the following command in your R console:

install.packages("renv")

You can then check the installation by running:

renv::status()

Use renv to automatically resolve dependencies

The functionalities of laggedcor depend on multiple other packages to work correctly. To install them easily using renv, simply run the following command in your R console:

renv::restore()

It will create a project-specific environment by downloading the necessary packages if not installed, and only loading (linking)_ the necessary packages if installed (kind of like conda's environment, but not 100% the same, as it does not manage the R version).

Additional packages for R package development

renv only resolves the packages required for the successful compilation and execution of laggedcor. To develop a R package, you need to manually install the following packages:

install.packages(c("devtools", "roxygen2", "testthat", "knitr"))
# or using renv 👇
renv::install(c("devtools", "roxygen2", "testthat", "knitr"))

After installation, you can have a look at the "(package) development situation report", to both verify the successful installation and check your development environment.

devtools::dev_sitrep()

Install your modified code locally

Build your code locally

It is recommended to use the GUI in R studio to perform test build, building and testing (but you can also type the corresponding commands in your R console).

Navigate to the build tab in the upper right panel:

image

As you can see, there are four buttons in the top menu: Install, Test, Check and More. The functionality of those buttons are :

  • Install: install the package to your current local environment. After installing, you can use library(laggedcor) in other files (for example, running .Rmd files in vignettes), just like other packages
  • Test: run all available tests available. To run individual tests, one can open the corresponding test file and click the Run Test button on the top right corner of the upper left panel.
  • Check: it basically checks whether the package can be built properly and run tests.

image2

(Optional) activate the project for renv

You can optionally make renv automatically load the project local functions in current and all future R sessions by activating the project:

renv::activate()

Developing the package

(WIP)

(TODO) recommended development workflow

(TODO) add tests

Unit test

Regression test