[R] need help with barplot

John Kane jrkrideau at yahoo.ca
Wed Nov 29 15:38:12 CET 2006


--- Robertas Kavaliûnas
<robertas.kavaliunas at gmail.com> wrote:

> Hello,
> I do this
>
a=c(10.2,0.4,0.2,5.2,8.6,1.6,0.0,1.0,6.3,1.4,0.4,0.2)
> b=matrix(a,nrow=4)
>
rownames(b)=c("20/04/2002","21/04/2002","22/04/2002","23/04/2002")
> colnames(b)=c("p1","p2","p3")
> barplot(b,beside=T,col=(c("red","orange","yellow")))
> 
> then I have
>
http://www.mif.vu.lt/~roka5178/barplot1.JPG<http://www.mif.vu.lt/%7Eroka5178/barplot1.JPG>
> but I need to have
>
http://www.mif.vu.lt/~roka5178/barplot.JPG<http://www.mif.vu.lt/%7Eroka5178/barplot.JPG>
> how can i do this?
> i need to  to change axis x whit y

> Robertas


This is dirty code but it works. Just transpose the
matrix before you plot it.

a=c(10.2,0.4,0.2,5.2,8.6,1.6,0.0,1.0,6.3,1.4,0.4,0.2)
b= matrix(a,nrow=4)
rownames(b)=c("20/04/2002","21/04/2002","22/04/2002","23/04/2002")
colnames(b)=c("p1","p2","p3")
b1 <- t(b)#  Transpose of 'b'
barplot(b1,beside=T,col=(c("red","orange","yellow")))



More information about the R-help mailing list