Description Usage Arguments Details Examples
From an input data frame with columns x, y and z, this function
creates a list with elements x, y and z in a format suitable for passing to
functions image
, contour
or
persp
. The coordinates in data
are assumed to come
from a 2D grid of points.
1 |
data |
a data frame with columns x and y being Cartesian coordinates, and z being the values of some variable at each coordinate. |
plot |
if |
contour |
if |
key |
logical for whether or not to include key when |
... |
other arguments to pass to |
Sorts z on values of x first, then y, then creates a matrix of z-values from this. Returns a list with elements x (unique values of x, in increasing order), y (unique values of y, in increasing order) and z (matrix of z-values in appropriate order for image/contour/persp).
If the original z is a factor variabele, the z returned is a matrix of integers between 1 and length(levels(z)) and the output list has an attributes called “facnames” that is a character vector containing the levels as factor variables, with z=1 corresponding to the first name, z=2 to the second, etc.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | data(Boland.alt)
op = par(no.readonly = TRUE)
par(mfrow = c(1,1))
# make object for use with image
imagedata = prep4image(Boland.alt, plot = FALSE)
image(imagedata, asp = 1)
contour(imagedata, add = TRUE)
# use directly for plotting
prep4image(Boland.alt, asp = 1)
prep4image(Boland.alt, asp = 1, contour = FALSE)
prep4image(Boland.alt, asp = 1, key = FALSE)
prep4image(Boland.alt, asp = 1, contour = FALSE, key = FALSE)
par(op)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.