There is a bit of a trap for young players involved, but: > x <- NA > is.real(x) [1] FALSE > x <- c(1,NA) > is.real(x[2]) [1] TRUE > x <- as.real(NA) > is.real(x) [1] TRUE > typeof(x) [1] "double" > x <- NA > typeof(x) [1] "logical" It makes sense when you think it through: An ``NA'' could be anything on its own. When it's an entry of a vector with real entries then it oughta be a ``not available real''. It's a bit subtle when you first bump into it, but it all clicks into place. Be that as it may --- to avoid the trap, use is.na() if you want to check whether a value is missing. cheers, Rolf Turner
Creating Dummy Variables with if else phrase
1 message · Rolf Turner