NaN is removed when using na.rm=TRUE

后端 未结 2 1757
旧时难觅i
旧时难觅i 2020-12-17 20:48

This reproducible example is a very simplified version of my code:

x <- c(NaN, 2, 3)

#This is fine, as expected
max(x)
> NaN

#Why does na.rm remove N         


        
2条回答
  •  一向
    一向 (楼主)
    2020-12-17 21:40

    It's a language decision:

    > is.na(NaN)
    [1] TRUE
    

    is.nan differentiates:

    > is.nan(NaN)
    [1] TRUE
    > is.nan(NA)
    [1] FALSE
    

    So you may need to call both.

提交回复
热议问题