Skip to content
Prev 156217 / 398506 Next

Unexpected returned value from a function

What you want is

ConvertMissingToNA <- function (values) {
   values[ values == -9999 | values == -999999] <- NA
   return( values )
}

To see why your version doesn't do what you wanted, maybe it helps to
consider the following?

x <- 1:10
y <- (x[3:6] <- 99)
y ## 99

(It's perhaps not entirely obvious that the value of y should be 99
and not c(99,99,99,99), but anyway, neither correspond to what you
wanted.)

Dan
On Tue, Sep 16, 2008 at 03:19:53PM -0700, Hutchinson,David [PYR] wrote: