[R] barplot as Trellis graphic

Agustin Lobo Agustin.Lobo at ija.csic.es
Thu Mar 27 18:47:04 CET 2008


Thanks, it was a matter of reshaping the data matrix as I usually have 
it, ie:
datos <- 
data.frame(x=abs(round(rnorm(100,10,5))),y=abs(round(rnorm(100,2,1))),f=factor(round(runif(100,1,3))))

to become:

datos2 <- 
data.frame(V1=c(datos[,1],datos[,2]),"VAR"=c(rep("x",100),rep("y",100)),f=factor(c(datos[,3],datos[,3])))

and then
require(lattice)
barchart(V1~VAR|f,data=datos2)

I get horizontal lines in the bars that I do not understand, though.

Agus




Deepayan Sarkar escribió:
> On 3/26/08, Agustin Lobo <Agustin.Lobo at ija.csic.es> wrote:
>> Dear list,
>>
>>  Is there any way of making barplots as a Trellis graphic?
> 
> Yes, the function to use is 'barchart'.
> 
> -Deepayan
> 

-- 
Dr. Agustin Lobo
Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
LLuis Sole Sabaris s/n
08028 Barcelona
Spain
Tel. 34 934095410
Fax. 34 934110012
email: Agustin.Lobo at ija.csic.es
http://www.ija.csic.es/gt/obster



More information about the R-help mailing list