setting key boxes in xyplot
On Apr 30, 2009, at 10:35 AM, Steve_Friedman at nps.gov wrote:
I thought I mimicked the coded correctly, but find an error/omission somewhere in the xyplot function shown below.
eggs # alligator egg fate
dput(round(eggs, 2), file = "")
structure(list(Year = c(1985, 1986, 1987, 1988, 1989, 1990, 1991,
1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000), NumEggs =
c(323,
1729, 1127, 104, 267, 291, 352, 478, 532, 569, 263, 490, 244,
428, 527, 670), Failed = c(183, 199, 257, 503, 99, 139, 273,
NA, 0, 55, 237, 581, 271, 144, 117, 43), Mean = c(0.29, 0.49,
0.55, 0.45, 0.26, 0.34, 0, 0.49, 0.77, 0.57, 0.77, NA, 0.69,
0.64, 0.51, 0.66), Eggs.p = c(0.19, 1, 0.65, 0.06, 0.15, 0.17,
0.2, 0.28, 0.31, 0.33, 0.15, 0.28, 0.14, 0.25, 0.3, 0.39), Fail.p =
c(0.31,
0.34, 0.44, 0.87, 0.17, 0.24, 0.47, NA, 0, 0.09, 0.41, 1, 0.47,
0.25, 0.2, 0.07)), .Names = c("Year", "NumEggs", "Failed", "Mean",
"Eggs.p", "Fail.p"), row.names = c("1985", "1986", "1987", "1988",
"1989", "1990", "1991", "1992", "1993", "1994", "1995", "1996",
"1997", "1998", "1999", "2000"), class = "data.frame")
xyplot(Eggs.p + Fail.p + Mean ~ Year , data = eggs, cex = 0.8, pch
= c(2,
5),
panel = panel.superpose.2, main = "Alligator Nest Fate",
ylab = "Prop. of Total Number of Hatched Eggs \n Prop. of
Total
Flooded Eggs",
legend = list(right = list(fun = grid::textGrob("Mean HSI",
rot=90))), col=(1:3), type = c("b", "b", "h"),
key = list(text = list(c("Proportion Hatched R^2 = 0.13,
Proportion Flooded R^2 = -0.23, Mean HSI")),
col = c("black","red", "green")), columns = 3)
It runs without error on my machine ... after loading lattice. Perhaps you ought to provide the error message .... and the other usual needed information. See that nice compact but very imformative message at the bottom of this reply.
David David Winsemius, MD Heritage Laboratories West Hartford, CT