assertthat
assertthat copied to clipboard
confusing error message for is.numeric()
The x is a matrix, the error message still refers to a vector.
library(assertthat)
x <- matrix(1:4, ncol = 2)
is.numeric(x) # returns TRUE
assert_that(is.numeric(x)) # returns TRUE
x <- matrix(letters, ncol = 2)
is.numeric(x) # returns FALSE
assert_that(is.numeric(x)) # returns error "Error: x is not a numeric or integer vector"
@ThierryO I'm looking through assertthat issues today. Bet you forgot by now that you even wrote this one!
IMHO what you've reported is not actually a bug. base::is.numeric literally tests whether the thing you pass to is it a numeric/integer vector. This assertion fails for exactly the reason stated...you passed it an object full of numbers that is not a vector.
Does that make sense?
@hadley I think we can close this issue