reshape_w: Reshape long to wide for perspective plots

Description Usage Arguments Details Value See Also Examples

Description

Safely reshape 'long' data.frame to 'wide' format suitable for 'persp', 'image', 'contour', 'filled.contour', 'heatmap', etc.

Usage

1

Arguments

data

data.frame of 3 columns, of which first two are x,y locations and third column is z values

...

further arguments passed to other methods

Details

Solves the dreaded "Error: increasing 'x' and 'y' values expected".

Value

List with components x$x and x$y for x and y axes, and x$z is a matrix containing the values to be plotted

See Also

matrify

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
set.seed(23)
d <- expand.grid(lon=seq(-125.5, -110.0, by=0.2),
                 lat=seq(40.5, 49.5, by=0.2))
d$z <- rnorm(nrow(d), 30, .2) * d$lat * d$lon
res <- reshape_w(d)
image(res)
contour(res, add=TRUE, lwd=2, nlevels=12)
persp(res, theta=0, phi=45)
filled.contour(res, color.palette=heat.colors)
heatmap(res$z)

phytomosaic/ecole documentation built on Jan. 2, 2022, 11:24 p.m.