R: How to use approx in more than one dimension (multidimensional interpolation)? -


this should no hard, searched lot , did not find solution far...

i dealing scattered data where

y = f(x1,x2,x3,..., xn) 

i create lookup function, gives me exact known values of y when entering vector x in data set, linearly interpolates when vector x not in data set.

basically approx(), higher number of dimensions.

to ease tryouts, here data:

y<-rnorm(27) x1<-seq(1,3,1) x2<-seq(10,30,10) x3<-seq(100,300,100)  df<-expand.grid(x1,x2,x3) df<-cbind(y,df) names(df)<-c("y","x1","x2","x3")  # task create function #   fun(x1,x2,x3) --> interpolated y  # expected output example: # fun(1,10,100) --> -0.89691454 # fun(1.5,10,100) --> -0.3560327 


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -