Skip to content

Additional R packages

R has a rich ecosystem of packages. For reproducible projects it is recommended to use a project-local library manager such as renv so package versions are recorded and restored reliably.

Installing packages

The simplest way to install packages from CRAN is:

install.packages("PACKAGE_NAME")

If installation fails, try updating your R and the build tools and re-run install.packages().

If you prefer to manage a project environment with renv:

install.packages("renv")
renv::init()          # creates project-local library and lockfile
renv::install("PACKAGE_NAME")
renv::snapshot()      # records installed versions to renv.lock

If installation fails, try updating your R and the build tools and re-run renv::install().

After installing the package you can load the package using:

library(PACKAGE_NAME)

deSolve

deSolve provides solvers for ordinary differential equations (ODEs), differential algebraic equations (DAEs), and more See documentation.

Example usage:

library(deSolve)

decay <- function(t, y, parms) {
  with(as.list(c(y, parms)), {
    dy <- -k * y
    list(dy)
  })
}

y0 <- c(y = 1)
parms <- c(k = 0.5)
times <- seq(0, 10, by = 0.1)

out <- ode(y = y0, times = times, func = decay, parms = parms)
head(out)

FME

FME (Flexible Modelling Environment) contains tools for inverse modelling, parameter estimation, sensitivity analysis and model evaluation. It often works together with deSolve for model simulation. See the FME manual for examples and details.

Basic usage pattern:

library(FME)
library(deSolve)

# define model wrapper that returns model output for given parameters
modfun <- function(pars) {
  # run deSolve or other simulator and return model outputs (named vector or data.frame)
  # ...
}

# use modFit to estimate parameters from observed data
# fit <- modFit(f = costFunction, p = initialPars)