Skip to content
Prev 40360 / 63424 Next

NaN, Inf to NA

On 27/05/2011 11:52 AM, Marc Schwartz wrote:
In the commit yesterday I signalled an error for character or raw vector 
input, and this caused about 30 packages to fail testing.  I checked a 
couple of them, and they both had applied one of the functions to 
character data.  Before introducing the error, these tests were 
basically harmless.

One example had code like this:

stop.na.inf <- function(x) {
   if(any(is.na(x)) | any(is.infinite(x)))
         stop("Either an NA or an infinite in the data: ",
              deparse(substitute(x)), ".\n",
              "   Eliminate those values or use imputation")
}

This little utility function was used a lot, including on character 
data.  Since it is rather ugly to say which types are okay to pass, I've 
reverted that part of the change and am running new tests, I will commit 
soon.

(The test could be improved a little; I'll send advice to the author on 
that.  But I don't think we should require x not to be a character vector.)

Duncan Murdoch