我有这样的表(输入):
User Event
Mike error
Mike buy
Bony error
Bony like
Mike rate
Mike like
我需要保留事件(输出)中没有rate
的用户的所有日志:
User Event
Mike error
Mike buy
Mike rate
Mike like
感谢您的帮助!
答案 0 :(得分:2)
dplyr
解决方案可以是:
library(dplyr)
df %>%
group_by(User) %>%
filter(sum(Event == 'rate') > 0)
# User Event
# <fctr> <fctr>
#1 Mike error
#2 Mike buy
#3 Mike rate
#4 Mike like