I have COVID data. It gives the number of cases and deaths of European countries on certain dates. I need to select 10 countries and show the cases after the 1000th confirmed case by drawing a line. Countries are listed under a column titled countries, number of cases under a column titled case, number of deaths under a column titled deaths, and dates under a column titled date. The problem is that I don't know how to get the 1000th confirmed case numbers of countries and the number of cases thereafter. Here is the question: "c) The cumulative number of cases of 10 countries by days since 1000th confirmed case"
Here is my trying code:
library(utils)
COVID_data <-read.csv("https://opendata.ecdc.europa.eu/covid19/nationalcasedeath_eueea_daily_ei/csv", na.strings = "", fileEncoding = "UTF-8-BOM")
above100th_cases <- ten_countries_cases %>%
filter(Cumulative_cases_Austria >= 1000|
Cumulative_cases_Croatia >= 1000|
Cumulative_cases_Denmark >= 1000|
Cumulative_cases_Finland >= 1000|
Cumulative_cases_France >= 1000|
Cumulative_cases_Germany >= 1000|
Cumulative_cases_Greece >= 1000|
Cumulative_cases_Iceland >= 1000|
Cumulative_cases_Italy >= 1000|
Cumulative_cases_Spain >= 1000)
#Reshape the data set in order to draw line graphs
above100th_case.m <- melt(above100th_cases,id.vars = 1)
# 0 values were below 100th, then skip these values to reach better graphs
above100th.m <- above100th_case.m %>% filter(value>0)
#Draw the graph by using ggplot
ggplot(above100th.m, aes(x=dateRep, y= value, color=variable))+
geom_line(size=1)+
#Arrange y axis, by considering min&max cumulative number of cases
scale_y_continuous(breaks = c(seq(from =5000, to =9000000, by=1001000)))+
labs(x="Date",
y="Cumulative Case Number",
title="The Cumulative Number of Cases By Date") +
facet_wrap(~variable)+
theme_bw()
It is obviously wrong. I also tried to use filter(if() else) or when_case(), but I could not apply them. I hope, I could explain myself.