One function to detect NaN, NA, Inf, -Inf, etc.?

后端 未结 1 824
清歌不尽
清歌不尽 2020-12-02 13:08

Is there a single function in R that determines if a value is NA, NaN, Inf, -Inf, or otherwise not a well-formed number?<

相关标签:
1条回答
  • 2020-12-02 13:44

    You want is.finite

    > is.finite(NA)
    [1] FALSE
    > is.finite(NaN)
    [1] FALSE
    > is.finite(Inf)
    [1] FALSE
    > is.finite(1L)
    [1] TRUE
    > is.finite(1.0)
    [1] TRUE
    > is.finite("A")
    [1] FALSE
    > is.finite(pi)
    [1] TRUE
    > is.finite(1+0i)
    [1] TRUE
    
    0 讨论(0)
提交回复
热议问题