R 提取和使用数据集中的当前数据 df
按照您的要求,此输出为10行(每个区域2行),但要认识到,例如,美国报告的死亡人数和恢复人数都是美洲地区最多的。这意味着它出现了两次。伊朗和澳大利亚也是如此,因此只有7个独特的行R 提取和使用数据集中的当前数据 df,r,R,按照您的要求,此输出为10行(每个区域2行),但要认识到,例如,美国报告的死亡人数和恢复人数都是美洲地区最多的。这意味着它出现了两次。伊朗和澳大利亚也是如此,因此只有7个独特的行 df <- read.csv ('https://raw.githubusercontent.com/ulklc/covid19- timeseries/master/countryReport/raw/rawReport.csv', stringsAsFactors = FALS
df <- read.csv ('https://raw.githubusercontent.com/ulklc/covid19-
timeseries/master/countryReport/raw/rawReport.csv',
stringsAsFactors = FALSE)
yesterday <- function() Sys.Date() - 1L
yesterday()
# [1] "if it doesn't work yesterday()-1 do it"
库(tidyverse)
死亡百分比
筛选器(截止日期(天)=昨天())%>%
按地区划分的组别%>%
过滤器(死亡==最大(死亡))%>%
选择(日期=天,
国名,
区域
死
已恢复)
回收量(单位:df%)
筛选器(截止日期(天)=昨天())%>%
按地区划分的组别%>%
过滤器(已恢复==最大值(已恢复))%>%
选择(日期=天,
国名,
区域
死
已恢复)
全方位
library(tidyverse)
death_df <- df %>%
filter(as.Date(day) == yesterday()) %>%
group_by(region) %>%
filter(death == max(death)) %>%
select(Date = day,
countryName,
region,
death,
recovered)
recovered_df <- df %>%
filter(as.Date(day) == yesterday()) %>%
group_by(region) %>%
filter(recovered == max(recovered)) %>%
select(Date = day,
countryName,
region,
death,
recovered)
full_df <- bind_rows(death_df, recovered_df)
full_df
# A tibble: 10 x 5
# Groups: region [5]
Date countryName region death recovered
<chr> <chr> <chr> <int> <int>
1 2020/05/05 Australia Oceania 96 5889
2 2020/05/05 Algeria Africa 470 2067
3 2020/05/05 United Kingdom Europe 29427 0
4 2020/05/05 Iran Asia 6340 80475
5 2020/05/05 United States Americas 72241 199684
6 2020/05/05 Australia Oceania 96 5889
7 2020/05/05 Spain Europe 25613 154718
8 2020/05/05 Iran Asia 6340 80475
9 2020/05/05 United States Americas 72241 199684
10 2020/05/05 South Africa Africa 148 2746