tests/testthat/examples/interpolate_deSolve.R

interpolate <- function() {
  flux <- NULL
  k <- NULL
  C0 <- NULL
  initial <- function(t = 1, pars = NULL) {
    flux <<- approxfun(pars$flux_t, pars$flux_y)
    k <<- pars$k
    C0 <<- mean(flux(1:365)) / k
    C0
  }

  derivs <- function(t, y, .) {
    flux_t <- flux(t)
    list(flux_t - k * y)
  }

  list(derivs = derivs, initial = initial, t = c(1, 365))
}

Try the odin package in your browser

Any scripts or data that you put into this service are public.

odin documentation built on April 28, 2022, 9:05 a.m.