2
I have a DF
in long format and tested the following code:
library(tidycovid19) # Pacote do GitHub - https://github.com/joachim-gassen/tidycovid19
library(tidyverse)
updates <- download_merged_data(cached = TRUE)
teste <- updates %>%
mutate(newCases = confirmed - lag(confirmed, 1),
newCases = ifelse(newCases < 0, 0, newCases),
mm7d = rollmeanr(newCases, 7, fill = NA, allign = "left")) %>%
filter(country == "Australia")
max <- which.max(teste$mm7d)
teste <- teste[teste$date <= teste$date[max],]
This code applies a filter to return the highest value of a 7-day moving average and removes all data after that value. My question is: how can I apply this same code to several countries and plot them on a graph?
Countries I am using for example (in iso3 code)
paises <- c("BRA", "CHN", "USA", "ESP", "AUS", "COL", "ITA")