Skip to content

by/ NA/ barplot

2 messages · Jonathan Baron, Brian Ripley

#
It's nice to hear that this problem might be a bug, and
that it can be fixed with ylim.  I've been using the
following function to get around it for barplots of
matrices.  So, for example, if m1 is a matrix, I say
barplot(fill(m1))

fill <- function(x) {x[x=="NA"]<-0 ; return(x)}

Jon Baron
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Wed, 4 Jul 2001, Jonathan Baron wrote:

            
I've put in a fix for 1.3.1.  Not sure what the intentions were, but if it
worked when ylim was set (for vertical barplots) it should work if it is
unset.
Ouch!  Use is.na(x) not x=="NA".  The first is a proper test for NA or
NaN.  The second coerces to character and tests equality of strings.  This
is slower and not quite the same:
[1]   0   1  NA NaN
[1] FALSE FALSE  TRUE  TRUE
[1] FALSE FALSE  TRUE FALSE