Why does “hello” > 0 return TRUE?

后端 未结 1 1331
长情又很酷
长情又很酷 2020-12-11 16:50

Try it:

\"hello\" > 0

I tried using as.numeric(\"hello\") but it just gave me back NA. What gives?

相关标签:
1条回答
  • 2020-12-11 17:46

    Because 0 is coerced to "0". See help(">"):

     If the two arguments are atomic vectors of different types, one is
     coerced to the type of the other, the (decreasing) order of
     precedence being character, complex, numeric, integer, logical and
     raw.
    
    0 讨论(0)
提交回复
热议问题