polyprep {hacks} | R Documentation |
Formats data with missing values to be plotted
with the polygon
function.
polyprep(x1, x2 = NULL)
x1 |
a numeric vector. |
x2 |
an optional second vector. If unspecified,
it will be set equal to x1 . |
polyprep
is designed to be used in conjuction
with polygon
when missing values are found in
the data. The default behavior is to split x1
into pieces at each occurance of missing values, then
combine these pieces with the reverse of x2
, and
then reassembled the pieces back into a single vector.
Nathan Stephens
y <- c(LakeHuron) y <- ifelse(y > 580, NA, y-min(y)) yy <- polyprep(y, -y) xx <- as.numeric(names(yy)) plot(xx, yy, type = 'n') polygon(xx, yy, col = 2)