【发布时间】:2014-12-21 18:56:01
【问题描述】:
我正在尝试使用 count() 助手过滤行。
我想要输出的是map %>% count(StudentID) = 3 所在的所有行。
例如在下面的 df 中,它应该取出所有 StudentID 为 10016 和 10020 的行,因为它们只是其中的 2 个实例,而我想要 3 个。
StudentID StudentGender Grade TermName ScaleName TestRITScore
100 M 9 Fall 2010 Language Usage 217
100 M 10 2011-2012 Language Usage 220
100 M 9 Fall 2010 Reading 210
10016 M 6 Fall 2010 Language Usage 217
10016 M 6 Fall 2010 Mathematics 210
10020 F 7 Fall 2010 Language Usage 210
10020 F 7 Fall 2010 Mathematics 213
10022 F 8 Fall 2010 Language Usage 232
10022 F 9 2011-2012 Language Usage 240
10022 F 8 Fall 2010 Mathematics 242
如果我这样做:
count(df, StudentID)
那么它只给了我一个 2 列的 df,但我想保留我的 df 的所有列。这就是为什么我认为我应该使用过滤器。
【问题讨论】: