From: Marc Schwartz <MSchwartz_at_mn.rr.com>

Date: Sun 05 Jun 2005 - 00:19:53 EST

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 Sun Jun 05 00:26:19 2005

Date: Sun 05 Jun 2005 - 00:19:53 EST

On Sat, 2005-06-04 at 14:50 +0100, Dan Bolser wrote:

> This must be because of the "log='y'" option that I am using here.

*>
**> y <- c(2,4,6,8,NA,NA,NA,NA,18)
**>
**> barplot2(y,log='y')
**>
**> Above fails.
**>
**>
**> I appreciate that what I am trying to do is somewhat artificial (handle
**> zero values on a log scale), but it does reflect the data I have.
**>
**> I tried plot(..., type='h'), but that dosn't do the "beside=T" stuff that
**> I want to do.
**>
**> I am now trying things like...
**>
**> barplot2(
**> dat.y.plot + 0.11, # Dirty hack
**> offset=-0.1, #
**> xpd=F, #
**> log='y',
**> beside=T
**> )
**>
**> Which looks messy.
**>
**> Any way to cleanly handle NA values with barplot2 on a log scale
**> (log='y')?
*

<snip>

Dan,

You are actually close in the above example, using the 'offset' argument.

In this case, you still cannot use "NA"s, since their value is unknown and so must set these elements to zero. Then using a small offset value, you can adjust the base value of the y axis so that it is "just above" zero. This should result in a minimal shift of the bar values above their actual values and should not materially affect the plot's representation of the data.

Something like the following "should" work:

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

[1] 2 4 6 8 NA NA NA NA 18

> y[is.na(y)] <- 0

> y

[1] 2 4 6 8 0 0 0 0 18

barplot2(y, log = "y", offset = 0.01, las = 2)

Note also that if you follow the above with:

box()

The residual bars from the (0 + 0.01) values are covered with the plot region box, if that is an issue for you.

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 Sun Jun 05 00:26:19 2005

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