[R] barplot with factors problem

Uwe Ligges ligges at statistik.tu-dortmund.de
Sun Mar 7 17:57:27 CET 2010



On 07.03.2010 17:42, casperyc wrote:
>
> http://www.harding.edu/fmccown/R/#autosdatafile
> http://www.harding.edu/fmccown/R/#autosdatafile
>
> I am tring to get a barchat by factors,
> following the example in that link above.
>
> ===========================
> x=c(145,40,40,120,180,
> 	140,155,90,160,95,
> 	195,150,205,110,160,
> 	45,40,195,65,145,
> 	195,230,115,235,225,
> 	120,55,50,80,45
> 	)
>
> y2=c(
> 	rep(as.character(1),5),
> 	rep(as.character(2),5),
> 	rep(as.character(3),5),
> 	rep(as.character(4),5),
> 	rep(as.character(5),5),
> 	rep(as.character(6),5)
> 	)
>
> barplot(as.matrix(x,y2),beside=TRUE,col=rainbow(5))

You know that a matrix has exactly one mode?

I guess you want something like
barplot(matrix(x, ncol=6), beside=TRUE, col=rainbow(5))
but since you do not tell what you want to get ...

Uwe Ligges




> ===========================
>
> Why it does not seperate (by 'some' space) by the factors?
> like not recognising the factors (1,2,3,4,5,6)?
>
> Thanks.
>
> casper



More information about the R-help mailing list