[R] How to use: library lattice: barchart

Robert Baer rbaer at atsu.edu
Tue Mar 21 15:50:36 CET 2006


> 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,"

-------------------

> cbind(some numeric and not numeric columns)
>
> gives you all columns to be character and when you make data.frame
> from it it is converted to factors.
>
> so
>
> > abarley = data.frame(ayield,avariety,ayear,asite)
>
> brings you close but than you need ayear to be factor. Either convert
> it in data frame or on fly
Actually, as the warning suggests, you have all factors in the dataframe but
you need to convert ayield to a numeric.  Something like,

abarley = data.frame(cbind(as.numeric(ayield),avariety,ayear,asite))

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


____________________________
Robert W. Baer, Ph.D.
Associate Professor
Department of Physiology
A. T. Still University of Health Science
800 W. Jefferson St.
Kirksville, MO 63501-1497 USA




More information about the R-help mailing list