Learn R Programming

interp (version 1.1-6)

interp2xyz: From interp() Result, Produce 3-column Matrix

Description

From an interp() result, produce a 3-column matrix or data.frame cbind(x, y, z).

Usage

interp2xyz(al, data.frame = FALSE)

Value

a matrix (or data.frame) with three columns, called

"x", "y", "z".

Arguments

al

a list as produced from interp().

data.frame

logical indicating if result should be data.frame or matrix (default).

Author

Martin Maechler, Jan.18, 2013

See Also

expand.grid() is the “essential ingredient” of interp2xyz().

interp.

Examples

Run this code
data(akima)
ak.spl <- with(akima, interp(x, y, z, method = "akima"))
str(ak.spl)# list (x[i], y[j], z = [i,j])

## Now transform to simple  (x,y,z)  matrix / data.frame :
str(am <- interp2xyz(ak.spl))
str(ad <- interp2xyz(ak.spl, data.frame=TRUE))
## and they are the same:
stopifnot( am == ad | (is.na(am) & is.na(ad)) )

Run the code above in your browser using DataLab