更新时间:2022-12-09 21:58:35
您显然对将角色[month]用作Date变量不感兴趣.考虑到我没错,您可以执行以下操作:
You apparently are not interested in taking your Character [month] as a Date variable. Considering that I'm not wrong you could simply do something like this:
library(dplyr)
tab %>%
group_by(month, variable) %>%
summarise(a_sum=sum(amount),
a_mean=(mean(amount)))
并得到这个:
Source: local data frame [3 x 4]
Groups: month
month variable a_sum a_mean
1 1-Jan x 4000 2000
2 2-Feb y 3000 3000
3 2-Feb z 5000 5000