search for: convertmissingtona

Displaying 1 result from an estimated 1 matches for "convertmissingtona".

2008 Sep 16
4
Unexpected returned value from a function
...erstand why the function returns a unit vector (NA) instead of setting all values in the vector which have -9999 or -999999 to NA. When I apply the function in line, it appears to work correctly? Can someone enlighten me what I am doing wrong? Thanks in advance. David Here's my example: ConvertMissingToNA <- function (values) { return ( values[ values == -9999 | values == -999999] <- NA ) } d <- floor(runif(10, 1, 100)) pos <- floor (runif(5, 1, 10)) d[pos] <- -9999 pos <- floor (runif(2, 1, 10)) d[pos] <- -999999 print (d) # now apply function e <- ConvertMissingToNA (...