Pitch for the Corona plotly graph app

HE
2020-09-11

Goal of the app

  • The main goal of this app is to allow the user to compare two countries regarding deaths caused by the coronavirus.
  • The user interface (ui) allows users to select two countries/regions and a date range.
  • The server part generates the plot and calculates the duration of the selected date range.
  • The result is an interactive plotly map. With mouseover you can see the exact numbers for the respective countries on a given date.

The user interface

The user interface (ui) consists of three elements:

  1. 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.

  2. Select the second country: This should be self-explanatory. Default are the United States.

  3. 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 evaluation

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") 
  })

The result

Your result – for an example of Germany and Italy for the months of March and April – should like this:

plot of chunk unnamed-chunk-3