我上传了数据集。但是我该如何向那些在欧洲死亡的人展示。
df <- read.csv ('https://raw.githubusercontent.com/ulklc/covid19-timeseries/master/countryReport/raw/rawReport.csv')
europe <-- df[df$region =="Europe"]
df$death [europe]
我们只能过滤欧洲国家,并按国家/地区计算死亡人数。
这可以在基数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]