On Sat, 4 Jun 2005, Uwe Ligges wrote: >Dan Bolser wrote: >> 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) >> >> barplot(y) >> >> 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) >> >> barplot(y) >> >> However... >> >> I am actually using barplot2 to use the "log='y'" function, so I can't use >> zero values on a log scale... >> >> So I need... >> >> 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. > > >Actually, it works, at least for me (R-2.1.0, WinNT, but you have not >told us your details!). > >BTW: In the meantime package gregmisc has been superseded by the >gregmisc bundle, and later on by a number of packages (such as gtools, >gdata, ...). > >Your setup seems to be rather outdated.
yeah :( R 2.0.0 (2004-10-04). I will upgrade to 2.1.0 (latest stable?) Instead of gregmisc what should I use to get barplot2? Will barplot() ever become barplot2() I will try upgrading.... Dan. > >Uwe Ligges > > > >> Am I missing something? >> >> >> To avoid confusion here is my data... >> >> >>>dat.y.plot >> >> [,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 6 >> attr(,"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 > ______________________________________________ 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