我目前正在从事机器学习项目。我有一个很大的数据集,是从论坛www.stormfront.com上刮下来的。数据集有7列:stormfront_self_content(论坛帖子),stormfront_lang_id,stormfront_publication_date,stormfront_topic,stormfront_docid,stormfront_category,stormfront_user。
我想选择一组已经在论坛上注册了一年以上的用户,已经写了500多个帖子,但是我不确定该怎么做。
任何帮助将不胜感激。
[假设您有代表每个用户的id
列,我们可以group_by
每个id
选择具有超过500行以及其发布日期之间max
和min
之间的天数为多的组大于365。
library(dplyr)
library(lubridate)
df %>%
mutate(stormfront_publication_date = ymd_hms(stormfront_publication_date)) %>%
group_by(id) %>%
filter(n() > 500 & difftime(max(stormfront_publication_date),
min(stormfront_publication_date),units = 'days') > 365)