【发布时间】:2022-08-18 01:54:27
【问题描述】:
我有以下数据集:
| Geography | Sex | Year | Population |
|---|---|---|---|
| AB | F | 2000 | 45320 |
| AB | M | 2000 | 42220 |
| ON | F | 2001 | 51230 |
| ON | M | 2001 | 51422 |
我想按省和年份汇总人口,例如,我将得到 46752 作为 2001 年 AB 的人口。
我尝试过使用dplyr 和summarise,但一直卡住。
这是我到目前为止所拥有的:
count_province <- df %>% group_by(Geography, Year, Population) %>% summarise(
prov_pop = sum(Population))
-
您的示例中没有任何行在您的表中有 AB & 2001...
标签: r