首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何对每个客户每月的电子邮件进行汇总

如何对每个客户每月的电子邮件进行汇总
EN

Stack Overflow用户
提问于 2022-05-13 10:24:38
回答 1查看 25关注 0票数 0

对于我的硕士论文,我试着总结一下顾客在所有可能的时间(每月)的通讯中所拥有的全部选择。我没能做到。

用于复制集合的Dput()数据:

代码语言:javascript
复制
structure(list(GroupID = c(404712L, 404722L, 404722L, 404722L, 
404722L, 404731L, 404731L, 404731L, 404731L, 404776L, 404776L, 
404776L, 404776L, 404845L, 404845L), MailingListName = c("Ticketing", 
"Merchandise", "Nieuwsbrief", "Partners", "Ticketing", "Merchandise", 
"Nieuwsbrief", "Partners", "Ticketing", "Merchandise", "Nieuwsbrief", 
"Partners", "Ticketing", "Merchandise", "Nieuwsbrief"), OptIn = c("1", 
"0", "0", "0", "0", "1", "1", "0", "1", "1", "1", "0", "1", "1", 
"1"), modifieddate = structure(c(17454, 17957, 17957, 17957, 
17957, 17455, 17455, 17455, 17455, 17901, 17901, 17901, 17901, 
18665, 18665), class = "Date"), modifieddate_Yr_Month = c("2017-10", 
"2019-03", "2019-03", "2019-03", "2019-03", "2017-10", "2017-10", 
"2017-10", "2017-10", "2019-01", "2019-01", "2019-01", "2019-01", 
"2021-02", "2021-02")), row.names = c(NA, -15L), class = c("data.table", 
"data.frame"))

我试过dplyr

代码语言:javascript
复制
   library(dplyr)
    dfnewsletters_total <- dfnewsletters %>%
      group_by(OptIn, GroupID, modifieddate_Yr_Month) %>%
      mutate(OptIn_Total = n()) %>%
      arrange(desc(OptIn_Total))

没有任何好的结果。

有人知道怎么解决这个问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-05-13 10:34:11

新闻通讯?

代码语言:javascript
复制
library(dplyr)
dfnewsletters %>%
  filter(MailingListName == "Nieuwsbrief") %>% 
  group_by(GroupID, modifieddate_Yr_Month) %>%
  summarise(OptIn_Total = sum(as.numeric(OptIn))) %>% 
  arrange(desc(OptIn_Total))

输出:

代码语言:javascript
复制
GroupID modifieddate_Yr_Month OptIn_Total
    <int> <chr>                       <dbl>
1  404731 2017-10                         1
2  404776 2019-01                         1
3  404845 2021-02                         1
4  404722 2019-03                         0
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72228049

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档