R 在一个数据帧上或使用data.table按顺序进行多个聚合

R 在一个数据帧上或使用data.table按顺序进行多个聚合,r,aggregation,R,Aggregation,我正在尝试汇总以下列列 "Module" "Timestamp" "SessionName" "MinutesDelivered" "UserName" "ViewingType" "TimestampDate" 所以我试图用列的组合按一定的顺序得到上面的总数 本质上是在特定日期使用特定会话名称的用户名的出现 例如,“Johny”在2018年5月12日登录3节文化课,“Mary”在2018年5月15日登录5节重复性劳损课 我想知道在R中是否有一个函数可以做到这一点,我已经研究了plyr::dd

我正在尝试汇总以下列列

"Module" "Timestamp" "SessionName" "MinutesDelivered" "UserName" "ViewingType" "TimestampDate"
所以我试图用列的组合按一定的顺序得到上面的总数

本质上是在特定日期使用特定会话名称的用户名的出现

例如,“Johny”在2018年5月12日登录3节文化课,“Mary”在2018年5月15日登录5节重复性劳损课

我想知道在R中是否有一个函数可以做到这一点,我已经研究了plyr::ddply、plyr::count和base R中的聚合。但是我想知道我的方法是否错误,我应该为每个会话/日期/用户将它们分解成单独的表,还是有办法在data.tables中做到这一点

下面是dput()


你能用dput()做一个可复制的例子吗?假设你把它转换成data.table(例如,
DTThank you@digEmAll),我不得不读一读data.table,语法可能很复杂,但我明白了,谢谢
structure(list(Module = c("LW3316", "LW3316", "LW3316", "LW3316", 
"LW3316", "LW3316", "LW3316", "LW3316", "LW3316", "LW3316", "LW3316", 
"LW3316", "LW3316", "LW3316", "LW3316", "LW3316", "LW3316", "LW3316", 
"LW3316", "LW3316", "LW3316", "LW3316", "LW3316", "LW3316", "LW3316", 
"LW3316", "LW3316", "LW3316", "LW3316", "LW3316", "LW3316", "LW3316", 
"LW3316", "LW3316", "LW3316", "LW3316", "LW3316", "LW3316", "LW3316", 
"LW3316", "LW3316", "LW3316", "LW3316", "LW3316", "LW3316", "LW3316", 
"LW3316", "LW3316", "LW3316", "LW3316"), Timestamp = structure(c(1505150699, 
1505151162, 1505152271, 1505162284, 1505220287, 1505220576, 1505243735, 
1505314660, 1505329575, 1505333453, 1505409497, 1505653851, 1505673294, 
1505682757, 1505723994, 1505735318, 1506000530, 1506000945, 1506007655, 
1506026131, 1506026495, 1506027981, 1506085966, 1506209482, 1506256877, 
1506277180, 1506280734, 1506340129, 1506351107, 1506938483, 1506949182, 
1506949619, 1506949637, 1506954271, 1507389553, 1507389554, 1507390707, 
1507480298, 1507636241, 1507667557, 1507808686, 1507818563, 1507841392, 
1508366237, 1508368180, 1508508172, 1508513010, 1508513049, 1508513340, 
1508513362), class = c("POSIXct", "POSIXt"), tzone = "UTC"), 
    SessionName = c("LW3316 on 9/11/2017 (Mon)", "LW3316 on 9/11/2017 (Mon)", 
    "LW3316 on 9/11/2017 (Mon)", "LW3316 on 9/11/2017 (Mon)", 
    "LW3316 on 9/11/2017 (Mon)", "LW3316 on 9/11/2017 (Mon)", 
    "LW3316 on 9/11/2017 (Mon)", "LW3316 on 9/11/2017 (Mon)", 
    "LW3316 on 9/11/2017 (Mon)", "LW3316 on 9/11/2017 (Mon)", 
    "LW3316 on 9/11/2017 (Mon)", "LW3316 on 9/11/2017 (Mon)", 
    "LW3316 on 9/11/2017 (Mon)", "LW3316 on 9/11/2017 (Mon)", 
    "LW3316 on 9/11/2017 (Mon)", "LW3316 on 9/18/2017 (Mon)", 
    "LW3316 on 9/11/2017 (Mon)", "LW3316 on 9/11/2017 (Mon)", 
    "LW3316 on 9/11/2017 (Mon)", "LW3316 on 9/18/2017 (Mon)", 
    "LW3316 on 9/11/2017 (Mon)", "LW3316 on 9/11/2017 (Mon)", 
    "LW3316 on 9/11/2017 (Mon)", "LW3316 on 9/11/2017 (Mon)", 
    "LW3316 on 9/18/2017 (Mon)", "LW3316 on 9/18/2017 (Mon)", 
    "LW3316 on 9/11/2017 (Mon)", "LW3316 on 9/25/2017 (Mon)", 
    "LW3316 on 9/25/2017 (Mon)", "LW3316 on 9/18/2017 (Mon)", 
    "LW3316 on 9/18/2017 (Mon)", "LW3316 on 9/18/2017 (Mon)", 
    "LW3316 on 9/25/2017 (Mon)", "LW3316 on 10/2/2017 (Mon)", 
    "LW3316 on 10/2/2017 (Mon)", "LW3316 on 9/25/2017 (Mon)", 
    "LW3316 on 9/25/2017 (Mon)", "LW3316 on 9/25/2017 (Mon)", 
    "LW3316 on 10/9/2017 (Mon)", "LW3316 on 10/9/2017 (Mon)", 
    "LW3316 on 10/9/2017 (Mon)", "LW3316 on 10/9/2017 (Mon)", 
    "LW3316 on 10/9/2017 (Mon)", "LW3316 on 10/2/2017 (Mon)", 
    "LW3316 on 10/2/2017 (Mon)", "LW3316 20 October 2017 at 12:02:21", 
    "20 October 2017 at 12:48:25", "20 October 2017 at 14:28:43", 
    "LW3316 20 October 2017 at 12:02:21", "20 October 2017 at 12:48:25"
    ), MinutesDelivered = c(4.87966666666664, 1.75285, 1.20426666666667, 
    28.9991920666666, 4.25249816666662, 0.0704192166666667, 0.407210766666667, 
    5.45169568333334, 104.33214055, 21.53249713645, 8.00026251666665, 
    32.8035570268167, 97.0560580999999, 11.927976873, 0.842423333333264, 
    3.34293333333328, 32.6008951666667, 23.5674802833333, 72.0751911099997, 
    0.05312915, 13.0953792166667, 21.0956275666667, 110.812050533333, 
    0.582068705000057, 97.5797333333343, 39.5602278700001, 3.98265503333316, 
    3.06983356666667, 30.5694796, 0.0196552166666682, 5.00846043333334, 
    0.1166757, 1.15660625, 3.16763836666668, 13.6891576166668, 
    4.8705137, 0.118677966666655, 69.3671006786945, 2.16981438333333, 
    73.6285150499999, 30.0131027666667, 0.0219079938666667, 65.7004652833333, 
    0.292117699999998, 7.36973023333333, 1.59354231666667, 0.410658333333335, 
    0.981110616666665, 0.179261400000001, 1.24121838333333), 
    UserName = c("Celestina  ", "Milo  ", "Marian  ", "Beth  ", 
    "Yong  ", "Celestina  ", "Paulita  ", "Laurence  ", "Sammy  ", 
    "Monte  ", "Mary  ", "Natalie  ", "Gilda  ", "Peggie  ", 
    "Robin  ", "Jerry  ", "Ester  ", "Dannie  ", "Rosalee  ", 
    "Mari  ", "Alona  ", "Petra  ", "Percy  ", "Heidi  ", "Charis  ", 
    "Sanjuana  ", "Elin  ", "Dottie  ", "Tawanna  ", "Sherie  ", 
    "Lera  ", "Lina  ", "Celestina  ", "Celestina  ", "Caryn  ", "Roscoe  ", 
    "Kimberley  ", "Linn  ", "Sanjuana  ", "Sanjuana  ", "Lynn  ", 
    "Natalie  ", "Charley  ", "Jenni  ", "Patti  ", "Yevette  ", 
    "Rebbecca  ", "Natalie  ", "Natalie  ", "Georgiann  "), ViewingType = c("Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Embedded Viewer", "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand", 
    "Interactive Desktop On Demand", "Interactive Desktop On Demand"
    ), TimestampDate = structure(c(1505088000, 1505088000, 1505088000, 
    1505088000, 1505174400, 1505174400, 1505174400, 1505260800, 
    1505260800, 1505260800, 1505347200, 1505606400, 1505606400, 
    1505606400, 1505692800, 1505692800, 1505952000, 1505952000, 
    1505952000, 1505952000, 1505952000, 1505952000, 1506038400, 
    1506124800, 1506211200, 1506211200, 1506211200, 1506297600, 
    1506297600, 1506902400, 1506902400, 1506902400, 1506902400, 
    1506902400, 1507334400, 1507334400, 1507334400, 1507420800, 
    1507593600, 1507593600, 1507766400, 1507766400, 1507766400, 
    1508284800, 1508284800, 1508457600, 1508457600, 1508457600, 
    1508457600, 1508457600), class = c("POSIXct", "POSIXt"), tzone = "UTC")), .Names = c("Module", 
"Timestamp", "SessionName", "MinutesDelivered", "UserName", "ViewingType", 
"TimestampDate"), row.names = c(NA, -50L), class = c("tbl_df", 
"tbl", "data.frame"))