[R] Lattice question.
Rolf Turner
r.turner at auckland.ac.nz
Mon Mar 30 00:42:20 CEST 2009
Hi.
I am trying to do histograms in lattice, and I want to get both
counts and percents in the same plot. To try to be clearer ---
there are 3 levels to my factor; I'd like to get a 2 x 3 array
of plots where the top row consist of histograms by counts and
the bottom consists of (the corresponding) histograms by percent.
I tried the following:
# Demo.
library(lattice)
set.seed(42)
XX <- data.frame(y=runif(300,0,10),a=factor(sample(letters[1:3],300,
TRUE,c(0.5,0.3,0.2))))
XX <- rbind(XX,XX)
XX$gps <- rep(c(1,2),each=300)
print(histogram(~y|a*gps,as.table=TRUE,data=XX, panel=function
(x,...,type) {
panel.histogram(x,...,type=c("count","percent")[gps])
}
))
But I got 2 x 3 array of plots each containing only the text string
``Error using packet
<1, ..., 6> object "gps" not found.''
I tried various other fiddle-arounds and got nowhere.
Is it possible to do what I want? If so, how?
Thanks.
cheers,
Rolf
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
More information about the R-help
mailing list