为什么"hello"> 0返回TRUE?

use*_*894 8 r

试试吧:

"hello" > 0
Run Code Online (Sandbox Code Playgroud)

我尝试过使用,as.numeric("hello")但它只是让我回来了NA.是什么赋予了?

Jos*_*ich 13

因为0被胁迫"0".见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.
Run Code Online (Sandbox Code Playgroud)