仅选择在多于两行中存在相同值的行

时间:2018-10-22 21:18:50

标签: r

我有一个数据框,如下所示:

ID    Text    
1234   fsfds
1234   sgge
1234   adfdf
543    sfsf
23     qfsg
23     swfr
6435   iuhg
6435   sonf
6435   ooos

我只想选择ID出现3次以上的列,以使期望的输出

ID    Text
1234   fsfds
1234   sgge
1234   adfdf
6435   iuhg
6435   sonf
6435   ooos

如何仅在一个列中选择具有相同值的列?

我尝试了这个但出现了错误

library(dplyr)
    myData %>% group_by(ID) %>%
      slice(sort(c(which(ID), which(ID) + 1)))

Error in slice_impl(.data, dots) : 
  Evaluation error: argument to 'which' is not logical.

1 个答案:

答案 0 :(得分:2)

您想要import pkg_resources # access the filepath: filepath = pkg_resources.resource_filename('root', 'config.txt') # access the contents as string: contents = pkg_resources.resource_string('root', 'config.txt') # access the contents as file-like object: contents = pkg_resources.resource_stream('root', 'config.txt')

filter()

仅保留多于2行的组。

相关问题