We want to plot the number of cumulative cases for Indonesia, Malaysia, and Singapore in 2020 - 2022
Start date = 2020-01-04
End date = 2022-12-31
library(plotly)
country_select <- c("Indonesia", "Malaysia", "Singapore")
date_range <- c("2020-01-04", "2022-12-31")
#Filter the date and country
datacountry <- coviddata[coviddata$Country %in% country_select, ]
data <- datacountry[datacountry$Date_reported >= date_range[1] & datacountry$Date_reported <= date_range[2], ]
#Plot with plot_ly
p <- plot_ly(data, x = ~Date_reported, y = ~Cumulative_cases, mode = "lines+markers", type = "scatter", color = ~Country,
text = ~paste("Country:", Country, "(", Country_code, ")", "<br>WHO Region:", WHO_region,
"<br>New cases:", New_cases, "<br>Cumulative cases:", Cumulative_cases), hoverinfo = "text")
p