library(pacman) p_load(deSolve) yini = 63 temps <- matrix(ncol=2,byrow=TRUE,data=c( 1, 0.654, 2, 0.167, 3, 0.060, 4, 0.070, 5,0.277, 6,0.186, 7,0.140, 8, 0.255, 9, 0.231, 10, 0.309)) T <- approxfun( x = temps[,1], y = temps[,2], method = "linear", rule = 2) sediment <- function(t, y, k) list (c( T(t)-y), T(t)) Out <- ode( times = 1:365, func = sediment, y = yini, parms = NULL) head(Out)