integrate a function in r (wrong length) -
i facing problem “integrate” command in r , don’t know how solve it, how deal extremely appreciated!
i have data have fitted function using nls command. integrate function on range (e.g. 2-20), in case illustrates fluorescence 2-20 meters in water column – in function.
the way tried it:
depth <- seq(0,100, by=.1) #### first making vector simulates depth (have real once in own data set). flu <- 0.216 + 0.140*depth + (-0.01538*(depth^2)) + 0.0004134*(depth^3) ### fitted function. integrand <- function(depth) {flu} integrate(integrand, lower= 2, upper= 20) when this, r says: error in integrate(integrand, lower = 2, upper = 20) : evaluation of function gave result of wrong length
i have tried vectorize flu function , integrate again, doesn’t help. maybe floating points? don’t know how deal this.
hope can me - time , in advance!!! søren
depth <- seq(0,100, by=.1) flu <- function(depth) {0.216 + 0.140*depth + (-0.01538*(depth^2)) + 0.0004134*(depth^3) } integrate(flu, lower= 2, upper= 20) #7.170026 absolute error < 8e-14
Comments
Post a Comment