HE
2020-09-11
dat <- read.csv(file="time_series_covid19_deaths_global.csv")
head(dat[,c(2,220,221)], 3)
Country.Region X8.24.20 X8.25.20
1 Afghanistan 1389 1397
2 Albania 254 259
3 Algeria 1446 1456
The user interface (ui) consists of three elements:
Select the first country: Pick the first country for which you want to plot the corona deaths time series. For some countries, e.g. France or the United Kingdom, there are also different regions to select from. Default is Italy.
Select the second country: This should be self-explanatory. Default are the United States.
Select the date range: You can select the first and last date you want to show. When you click on a date, a calendar opens which you can use to choose the date. Default values are 2020-01-22 and 2020-09-07.
The server part evaluates the input and creates a plotly graph. As input, it takes the two countries selected by the user and limits the x-axis by the selected date range. Then, it prints the length of the date range below.
In order to keep this presentation down to 5 pages, here's the basic plot part of the server calculation:
fig <- data %>% plot_ly() %>%
add_lines(x = ~Date, y = ~country1, name=name1) %>%
add_lines(x = ~Date, y = ~country2, name=name2) %>%
And here's the calculation of the date length:
calc_sum <- reactive({
d2 <- input$date[2]; d1 <- input$date[1]
calc_sum <- paste("Length of selected dates:", as.character(d2-d1), "days")
})
Your result – for an example of Germany and Italy for the months of March and April – should like this: