我上传了数据集。但我该如何向那些在欧洲死去的人展示。
df <- read.csv ('https://raw.githubusercontent.com/ulklc/covid19-timeseries/master/countryReport/raw/rawReport.csv')
europe <-- df[df$region =="Europe"]
df$death [europe]
发布于 2020-05-03 10:49:16
我们也可以在subset
中使用aggregate
aggregate(death~countryName, df, subset = region =="Europe"), sum)
或者使用rowsum
with(subset(df, region == 'Europe'), rowsum(death, countryName))
发布于 2020-05-03 04:42:05
我们只能过滤欧洲国家,并按国家计算死亡人数。
这可以在基础R中完成:
df1 <- aggregate(death~countryName, subset(df, region =="Europe"), sum)
dplyr
library(dplyr)
df1 <- df %>%
filter(region == 'Europe') %>%
group_by(countryName) %>%
summarise(total_death = sum(death))
在data.table
中
df1 <- setDT(df)[region == 'Europe', (total_death = sum(death)), countryName]
https://stackoverflow.com/questions/61574213
复制相似问题