相关疑难解决方法(0)

关于"=="运算符的行为的解释

在下面这个非常简单的例子中,我无法理解"=="运算符的行为.

A <- c(10, 20, 10, 10, 20, 30)
B <- c(40, 50, 60, 70, 80, 90)

df <- data.frame(A, B)

df[df$A == c(10,20), ]      # it returns 3 lines instead of 5
df[df$A %in% c(10,20), ]    # it works properly and returns 5 lines
Run Code Online (Sandbox Code Playgroud)

大家先谢谢大家.

r

7
推荐指数
1
解决办法
286
查看次数

标签 统计

r ×1