如果一个观察值超过 3 行,有没有办法对我的数据框进行子集化?例如。我的数据看起来像:
ID Food Vegetable
aaa fruit lemon
bbb fruit lemon
ccc fruit sprout
ddd fruit lemon
eee fruit lemon
fff fruit watermelon
我希望它看起来像:
ID Food Vegetable
aaa fruit lemon
bbb fruit lemon
ddd fruit lemon
eee fruit lemon
结构:
structure(list(ID = c("aaa", "bbb", "ccc", "ddd", "eee", "fff"
), Food = c("fruit", "fruit", "fruit", "fruit", "fruit", "fruit"), Vegetable = c("lemon",
"lemon", "sprout", "lemon", "lemon", "watermelon")), class = "data.frame", row.names = c(NA,
-6L))
谢谢