knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 8.5,
  fig.height = 7
)

This vignette can describe the use of the CovidYe package, including how to launch the shiny application, what the application can do, and the guidelines for its users.

Installing CovidYe

The development version can be installed from my GitHub with:

# install.packages("devtools")
devtools::install_github("etc5523-2020/r-package-assessment-Year-97")

Launching shiny app

The main goal of CovidYe package is to provide a shiny app called Covid-19 to convey the daily information of Covid-19 in r length(unique(CovidYe::coronavirus$country)) countries and the overall trend of different type of cases.

library(CovidYe)
library(tibble)
library(dplyr)
library(tidyr)
library(plotly)
launch_app()

Exploration of the data in the CovidYe package

This package also provides the coronavirus dataset, which contains daily information for 118 countries over time. This data is sourced from WHO and coronavirus.

The following table and interactive plot are provided by the functions contained in that Shiny app. The visualization effects of displaying Covid-19 general information are attractive for the users.

The Daily Situation and Cumulative Cases:

From the coronavirus data set in CovidYe package, you can easily understand the new confirmed cases, death and recovered cases in each day of the world, and have a clear understanding of the most serious period of time.

coronavirus %>% 
  select(date, country, type, cases) %>% 
  group_by(type, date) %>%
  summarise(total_cases = sum(cases)) %>%
  pivot_wider(names_from = type, values_from = total_cases) %>%
  arrange(date) %>%
  mutate(totalconfirmed = cumsum(confirmed),
         totalrecovered = cumsum(recovered),
         totaldeath = cumsum(death)) %>% 
  head(15) %>% 
  kableExtra::kable(align = 'lrrrrrr', 
                     format.args = list(big.mark = ",")) %>% 
   kableExtra::kable_styling(
     font_size = 15,
     bootstrap_options = c("striped", "hover", "condensed")) 

The overall change trend of COVID-19:

I also provide a different way for users to understand the basic situation in my COVID-19 Shiny App which contains in CovidYe package, the interactive plots.

As shown in the figure below, users can learn about the specific situation of the day by clicking each point in the plot, which makes the content of the entire Shiny App more interesting and enables people to better understand the trend of COVID-19 epidemic situation.

corona_daily <- coronavirus %>% 
  select(date, country, type, cases) %>% 
  group_by(type, date) %>%
  summarise(total_cases = sum(cases)) %>%
  pivot_wider(names_from = type, values_from = total_cases) %>%
  arrange(date) %>%
  mutate(totalconfirmed = cumsum(confirmed),
         totalrecovered = cumsum(recovered),
         totaldeath = cumsum(death))

g <- plot_ly(corona_daily, 
                 x = ~ date, 
                 y = ~ totalconfirmed,
                 name = 'Confirmed',
                 fillcolor = 'pink',
                 type = 'scatter',
                 mode = 'none',
                 stackgroup = 'one') %>% 
      add_trace(y = ~totalrecovered, 
                name = 'Recovered', 
                fillcolor = 'lightgreen') %>%
      add_trace(y = ~ totaldeath, 
                name = "Death",
                fillcolor = 'black') %>%
      layout(title = "Distribution of Covid19 Cases Worldwide",
             legend = list(x = 0.1, y = 0.9),
             yaxis = list(title = "Number of Cases"),
             xaxis = list(title = "Date"),
             hovermode = "compare")

    ggplotly(g)

The Current Situation of COVID-19 in Top 10 countries with most confirmed cases:

In addition to the general trend of the COVID-19 epidemic situation, I also provide the specific situation of the top 20 countries with the most confirmed cases, and show them with the bubble map. When users click on each bubble, they can have a good idea about the situation of the specific country from the popup. Also the position of the bubbles have great significance to explore which can provide many useful information.

coronavirus_new <- coronavirus %>% 
  group_by(country, type) %>%
  summarise(total_cases = sum(cases)) %>%
  pivot_wider(names_from = type, values_from = total_cases) %>%
  arrange(-confirmed) %>%
  head(20) %>%
  mutate(recover_rate = recovered / confirmed,
         death_rate = death / confirmed) %>%
  ungroup() 


  plotly::plot_ly(y = ~ round(100 * coronavirus_new$recover_rate, 1),
                  x = ~ round(100 * coronavirus_new$death_rate, 1),
                  size = ~  log(coronavirus_new$confirmed),
                  sizes = c(5, 70),
                  type = 'scatter', 
                  mode = 'markers',
                  color = ~ coronavirus_new$country,
                  marker = list(sizemode = 'diameter' , opacity = 0.5),
                  hoverinfo = 'text',
                  text = ~paste("</br>", coronavirus_new$country, 
                                "</br> Confirmed Cases: ", coronavirus_new$confirmed,
                                "</br> Recovery Rate: ", paste(round(100 * coronavirus_new$recover_rate, 1), "%", sep = ""),
                                "</br> Death Rate: ",  paste(round(100 * coronavirus_new$death_rate, 1), "%", sep = ""))) %>%
  plotly::layout(yaxis = list(title = "Recovery Rate", ticksuffix = "%"),
                 xaxis = list(title = "Death Rate", ticksuffix = "%", 
                              dtick = 1, 
                              tick0 = 0)) 

Noted

Also there are two functions after refactoring in the package which can simplify the input selection in the Shiny app and the process of making formatted tables. You can find that in the pckdown site.



etc5523-2020/r-package-assessment-Year-97 documentation built on Jan. 1, 2021, 1:11 a.m.