假设数据框是这样的:
df <- data.frame(x = c("a", "a", "b", "a", "c"), y = c("001", "002", "003", "004", "005"))
Run Code Online (Sandbox Code Playgroud)
我只想保留记录:
x y b 003 c 005
为了得到这个结果,我这样做了:
df %>% filter (count(x)<2) -> df1
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误:
Error: no applicable method for 'group_by_' applied to an object of class "factor"
Run Code Online (Sandbox Code Playgroud)
谁能告诉我如何解决这个问题?谢谢!