[R] [Beginner] Issue with the barplot function

Jim Lemon jim at bitwrit.com.au
Sat Oct 10 11:07:13 CEST 2009


On 10/10/2009 06:34 PM, tulesparo wrote:
> Hello,
>
> I am a beginner with R and I would need some help with doing the barplot I
> want.
>
> In fact I want to draw a barplot from my table, but the issue is that only
> the modalities with nonzero values are plotted ; the fact is that I would
> plot all the modalities, including those which have no value.
>
> If I'm not clear, here is an example : let X, Y and Z be three modalities
> which have respectively 2, 0 and 3 values ; my current barplot only draws X
> and Z, and I also would draw Y.
>
>
>    
Hi tulesparo,
If you mean something like this:

xyz<-matrix(c(2,6,NA,NA,NA,NA,4,7,1),ncol=3)
barplot(xyz,beside=TRUE)

you can get zero height bars for y like this:

xyz[is.na(xyz)]<-0
barplot(xyz,beside=TRUE)

> PS : Sorry if I've made mistakes, I'm French...
>    
Ne vous inquiétez pas, mon ami, ce n'est pas votre faute.

Jim



More information about the R-help mailing list