项目作者: etc5523-2020

项目描述 :
r-package-assessment-YIWEN-JIANG-github created by GitHub Classroom
高级语言: R
项目地址: git://github.com/etc5523-2020/r-package-assessment-YIWEN-JIANG-github.git


COVID19dashboard

R build
status
License: GPL
v3
GitHub
commit

Overview

The goal of COVID19dashboard package is to provide datasets and
functions to run the COVID-19 shiny dashboard.

The COVID-19 shiny dashboard, first launched on Oct 2020, aims to
complement existing COVID-19 mapping dashboards (such as those developed
by the WHO) with several interactive
features, including the timeline function and the ability to compare
between countries.

Installation

The development version can be installed from
GitHub with:

  1. # install.packages("devtools")
  2. devtools::install_github("etc5523-2020/r-package-assessment-YIWEN-JIANG-github")

Get started

The data set records COVID-19 information since Dec 31, 2019, and
provided by Our World in Data.

The package includes three data, which are covid_raw, visitor_map
and visitors_total.

  • covid_raw: The data comes from covid_raw.rda. The data contains
    the COVID-19 information of 210 countries since Dec 31, 2019.
  • visitors_total: The data comes from visitors_total.rda. The data
    contains information on how the number of visitors changes sine
    pandemic for different places.
  • visitor_map: The data comes from visitor_map.rda. The data added
    geometric information compare to visitors_total, it can be used to
    create a map plot.

Shiny interface (How to run the app)

By using the launch_app() function to run the shiny dashboard. This
app aims to complement the raw data by providing interactive
visualisation and used to compare the difference between the countries.

  1. launch_app()

A screenshot of the interface is provided below.

shiny interface

Example

This is a basic example which shows you the COVID-19 data in this
package:

  1. library(COVID19dashboard)
  2. #> Loading required package: shiny
  3. #> Loading required package: tibble
  4. #> Loading required package: shinydashboard
  5. #>
  6. #> Attaching package: 'shinydashboard'
  7. #> The following object is masked from 'package:graphics':
  8. #>
  9. #> box
  10. library(tibble)
  11. covid_raw
  12. #> # A tibble: 46,484 x 41
  13. #> iso_code continent location date total_cases new_cases new_cases_smoot…
  14. #> <chr> <chr> <chr> <date> <dbl> <dbl> <dbl>
  15. #> 1 AFG Asia Afghani… 2019-12-31 0 0 NA
  16. #> 2 AFG Asia Afghani… 2020-01-01 0 0 NA
  17. #> 3 AFG Asia Afghani… 2020-01-02 0 0 NA
  18. #> 4 AFG Asia Afghani… 2020-01-03 0 0 NA
  19. #> 5 AFG Asia Afghani… 2020-01-04 0 0 NA
  20. #> 6 AFG Asia Afghani… 2020-01-05 0 0 NA
  21. #> 7 AFG Asia Afghani… 2020-01-06 0 0 0
  22. #> 8 AFG Asia Afghani… 2020-01-07 0 0 0
  23. #> 9 AFG Asia Afghani… 2020-01-08 0 0 0
  24. #> 10 AFG Asia Afghani… 2020-01-09 0 0 0
  25. #> # … with 46,474 more rows, and 34 more variables: total_deaths <dbl>,
  26. #> # new_deaths <dbl>, new_deaths_smoothed <dbl>, total_cases_per_million <dbl>,
  27. #> # new_cases_per_million <dbl>, new_cases_smoothed_per_million <dbl>,
  28. #> # total_deaths_per_million <dbl>, new_deaths_per_million <dbl>,
  29. #> # new_deaths_smoothed_per_million <dbl>, new_tests <lgl>, total_tests <lgl>,
  30. #> # total_tests_per_thousand <lgl>, new_tests_per_thousand <lgl>,
  31. #> # new_tests_smoothed <lgl>, new_tests_smoothed_per_thousand <lgl>,
  32. #> # tests_per_case <lgl>, positive_rate <lgl>, tests_units <lgl>,
  33. #> # stringency_index <dbl>, population <dbl>, population_density <dbl>,
  34. #> # median_age <dbl>, aged_65_older <dbl>, aged_70_older <dbl>,
  35. #> # gdp_per_capita <dbl>, extreme_poverty <dbl>, cardiovasc_death_rate <dbl>,
  36. #> # diabetes_prevalence <dbl>, female_smokers <dbl>, male_smokers <dbl>,
  37. #> # handwashing_facilities <dbl>, hospital_beds_per_thousand <dbl>,
  38. #> # life_expectancy <dbl>, human_development_index <dbl>

There are four functions inside this package, which are:

  • launch_app(): Launch the COVID-19 shiny dashboard
  • add_comma(): Label numbers in decimal format (e.g. 1,234)
  • shiny_note(): Add a note box into shiny app
  • date_range(): Create date range input

Plotting the number of daily new cases in the United States

  1. library(tidyverse)
  2. #> ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
  3. #> ✓ ggplot2 3.3.2 ✓ dplyr 1.0.2
  4. #> ✓ tidyr 1.1.2 ✓ stringr 1.4.0
  5. #> ✓ readr 1.4.0 ✓ forcats 0.5.0
  6. #> ✓ purrr 0.3.4
  7. #> ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
  8. #> x dplyr::filter() masks stats::filter()
  9. #> x dplyr::lag() masks stats::lag()
  10. covid_raw %>%
  11. dplyr::filter(location == "United States") %>%
  12. ggplot() +
  13. geom_line(aes(x = date, y = new_cases)) +
  14. theme_classic() +
  15. ylab("Number of Daily New Cases") +
  16. xlab("Date") +
  17. ggtitle("Number of Daily New Cases in United States")

Data Source