I was trying to select some rows from a dataframe.
data(Grunfeld, package="AER")
gf = Grunfeld[Grunfeld$firm == c("General Electric",
"General Motors",
"US Steel",
"Westinghouse"), ]
The expected output would have 80 rows, but I got 20.
> dim(gf)
[1] 20 5
On the other hand, subset()
worked.
gf = subset(x = Grunfeld, firm %in% c("General Electric",
"General Motors",
"US Steel",
"Westinghouse"))
> dim(gf)
[1] 80 5
Anyone knows what is happening here?
Thanks in advance.