[R] by/ NA/ barplot
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Jul 4 11:49:51 CEST 2001
On Wed, 4 Jul 2001, Jonathan Baron wrote:
> 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
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.
> 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)}
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:
> x <- c(0, 1, NA, 0/0)
> x
[1] 0 1 NA NaN
> is.na(x)
[1] FALSE FALSE TRUE TRUE
> x == "NA"
[1] FALSE FALSE TRUE FALSE
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list