【发布时间】:2021-09-22 15:57:40
【问题描述】:
我试图从数据框中选择一些行。
data(Grunfeld, package="AER")
gf = Grunfeld[Grunfeld$firm == c("General Electric",
"General Motors",
"US Steel",
"Westinghouse"), ]
预期的输出应该是 80 行,但我得到了 20 行。
> dim(gf)
[1] 20 5
另一方面,subset() 起作用了。
gf = subset(x = Grunfeld, firm %in% c("General Electric",
"General Motors",
"US Steel",
"Westinghouse"))
> dim(gf)
[1] 80 5
有人知道这里发生了什么吗?
提前致谢。
【问题讨论】:
标签: r