[R] How to use: library lattice: barchart

paladini at rz.uni-potsdam.de paladini at rz.uni-potsdam.de
Tue Mar 21 12:05:27 CET 2006

Dear ladies and gentlemen!

In the help text for the xyplot (library(lattice), help(xyplot)) is an example
given how one can use barchart:

barchart(yield ~ variety | site, data = barley,
              groups = year, layout = c(1,6),
              ylab = "Barley Yield (bushels/acre)",
              scales = list(x = list(abbreviate = TRUE,
                            minlength = 5)))
I want my data to be represented just in the same way. But when I try it like

ayield = c(2,3,5,6,3,4,7,8,9,2,3,5,6,1,2,3,4,2,6,8)
avariety = c(rep("A",5),rep("B",5),rep("C",5),rep("D",5))
ayear = (c(rep(1931,10),rep(1932,10)))
asite = c(rep(c("iu","gt","jt","jhzt","tr"),4))
abarley = data.frame(cbind(ayield,avariety,ayear,asite))

barchart(ayield ~ avariety | asite, data = abarley,groups = ayear, layout =
c(1,5) )

it looks totaly different and I get the error message:
"x should be numeric in: bwplot.formula(x = ayield ~ avariety | asite, data =
list(ayield = c(2,"

What did I do wrong?
Can anybody help me?

Best regards, thank you very much

Claudia Paladini

More information about the R-help mailing list