创建了一个数据框:
simpleDF<- structure(list(vals = c(NA, NaN, 2)), .Names = "vals", row.names = c(NA,
-3L), class = "data.frame")
> is.na(simpleDF$vals)
[1] TRUE TRUE FALSE
> is.nan(simpleDF$vals)
[1] FALSE TRUE FALSE
现在,当我更改数据框以包含字符串值时:
simpleDF <- structure(list(vals = structure(c(NA, 2L, 1L, 3L), .Label = c("2",
"NaN", "test"), class = "factor")), .Names = "vals", row.names = c(NA,
-4L), class = "data.frame")
> is.na(simpleDF$vals)
[1] TRUE FALSE FALSE FALSE
> is.nan(simpleDF$vals)
[1] FALSE FALSE FALSE FALSE
我不明白为什么NaN
不再认可了is.nan()
?当然会有解释..