From: Dan Bolser <dmb_at_mrc-dunn.cam.ac.uk>

Date: Sat 04 Jun 2005 - 23:13:54 EST

[1]

"2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" ">12" [13] NA NA NA NA NA NA NA NA NA NA NA NA

*>
*

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jun 04 23:17:51 2005

Date: Sat 04 Jun 2005 - 23:13:54 EST

I want to include missing values in my barplot to get the correct x-axis, for example,

x <- c(1,2,3,4, 9)

y <- c(2,4,6,8,18)

The above looks wrong because the last height in y should be a long way over.

So I want to do something like...

x <- c(1,2,3,4,5,6,7,8, 9)

y <- c(2,4,6,8,0,0,0,0,18)

x <- c(1,2,3,4, 5, 6, 7, 8, 9)

y <- c(2,4,6,8,NA,NA,NA,NA,18)

barplot(y)

But that don't work.

To avoid confusion here is my data...

[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]

Ho 653 80 132 10 34 3 10 0 7 2 7 7 He 139 56 69 6 24 3 11 3 2 1 2 6attr(,"names")

[1]

"2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" ">12" [13] NA NA NA NA NA NA NA NA NA NA NA NA

And here is what I call...

barplot(dat.y.plot,

ylim=c(0,max(dat.y.plot + 50)), # I don't like the default beside=T, names.arg=c('2','3','4','5','6','7','8','9','10','11','12','>12'), cex.axis=1.5, cex.names=1.5, legend=T )

Which is fine (except I don't know why I still need names.arg).

Then I try...

library(gregmisc)

barplot2(dat.y.plot+1, log='y',

beside=T, names.arg=c('2','3','4','5','6','7','8','9','10','11','12','>12'), cex.axis=1.5, cex.names=1.5, legend=T )

Which fails because of the zero. If I try ...

dat.y.plot[dat.y.plot==0] <- NA

It fails because of the NA.

Any suggestions?

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jun 04 23:17:51 2005

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:32:22 EST
*