[R] interp function in package akima

David Winsemius dwinsemius at comcast.net
Mon Feb 8 23:58:21 CET 2010


On Feb 8, 2010, at 5:06 PM, Sacha Viquerat wrote:

> hello! does anyone know how to get values out of an interp object  
> (from akima package)? ive constructed an elevation map and would  
> like to numerically see the calculated z values of data points,  
> which were not empirically sampled (basically: id like to see the  
> altitude at locations x,y which have been computed by the interp  
> function. is there any way? thanks in advance!

Have you read the help page for interp???  The interp function returns  
a list, the third element of which is a matrix named "z":

interpFn <- interp( < arguments > )

interpFn$z  # should return that matrix

If your pick out a particular element associated with the 10th x-value  
and the 20th y-value, you should be able get the x,y,z triplet by

c(interpFn$x[10] , interpFn$y[20] ,interpFn$z[10,20] )

If you have particular x,y values you want to access then you need to  
include them in the xo[] and yo[] vectors supplied to interp().  
interp() does not provide interpolation between points on the output  
grid, at least as as I read the help page.
There are strategies that could do so. Whenever I estimate a crossed- 
spline model in package Design, I could extract a 2d-spline function  
if I chose to.

-- 

David Winsemius, MD
Heritage Laboratories
West Hartford, CT



More information about the R-help mailing list