Чтобы найти страны с наибольшим количеством пациентов
library(tidyverse)
df %>%
group_by(countryName) %>%
summarise(total = max(confirmed)) %>%
arrange(desc(total)) %>%
top_n(5) -> countries5
countries5
## A tibble: 5 x 2
# countryName total
# <chr> <int>
#1 United States 1768116
#2 Brazil 438812
#3 Russia 379051
#4 Spain 284986
#5 United Kingdom 269127
Построить график эволюции их confirmed
случаев.
countries5 %>%
left_join(df, by = 'countryName') %>%
select(countryCode, confirmed, day) %>%
mutate(day = as.Date(day)) %>%
filter(confirmed > 0) %>%
ggplot(aes(day, confirmed, color = countryCode)) +
geom_line()