The covid19swiss R package provides a tidy format dataset of the 2019
Novel Coronavirus COVID-19 (2019-nCoV) pandemic outbreak in Switzerland
cantons and the Principality of Liechtenstein (FL). The covid19swiss
dataset includes the following fields:
date
- the timestamp of the case, a Date
objectlocation
- the Cantons of Switzerland and the Principality
of Liechtenstein (FL) abbreviation codelocation_type
- description of the location, either Canton of
Switzerland or the Principality of echtensteinlocation_code
- a canton index code for merging geometry data from
the rnaturalearth package, ailable only for Switzerland cantonslocation_code_type
- the name of code in the rnaturalearth
package for Switzerland mapdata_type
- the type of casevalue
- the number of cases corresponding to the date
and
data_type
fieldsWhere the available data_type
field includes the following cases:
total_tested
- number of tests performed as of the datetotal_confirmed
- number of positive cases as of the datenew_hosp
- new hospitalizations with respect to the previously
reported datecurrent_hosp
- number of hospitalized patients as of the current
datecurrent_icu
- number of hospitalized patients in ICUs as of the
current datecurrent_vent
- number of hospitalized patients requiring
ventilation as of the current datetotal_recovered
- total number of patients recovered as of the
current datetotal_death
- total number of death as of the current dateMore information can be found the following vignettes:
Data source: Specialist Unit for Open Government Data Canton of Zurich, raw data is available on the following repository. Special thanks for all the people that collaborate and contribute to pull the data from multiple sources and make this data available!
You can install the released version of covid19swiss from CRAN with:
install.packages("covid19swiss")
Or, install the most recent version from GitHub with:
# install.packages("devtools")
devtools::install_github("Covid19R/covid19swiss")
The covid19swiss package dev version is been updated on a daily
bases. The update_swiss_data
function enables a simple refresh of the
installed package datasets with the most updated version on Github:
library(covid19swiss)
update_swiss_data()
More information about updating the data is available on this vignette
Note: must restart the R session after using the update_swiss_data
function in order to have the updates available
data(covid19swiss)
head(covid19swiss)
#> date location location_type location_code location_code_type data_type value
#> 1 2020-02-25 GE Canton of Switzerland CH.GE gn_a1_code total_tested 72
#> 2 2020-02-25 GE Canton of Switzerland CH.GE gn_a1_code total_confirmed 0
#> 3 2020-02-25 GE Canton of Switzerland CH.GE gn_a1_code new_hosp NA
#> 4 2020-02-25 GE Canton of Switzerland CH.GE gn_a1_code current_hosp 0
#> 5 2020-02-25 GE Canton of Switzerland CH.GE gn_a1_code current_icu 0
#> 6 2020-02-25 GE Canton of Switzerland CH.GE gn_a1_code current_vent 0
library(tidyr)
covid19swiss_wide <- covid19swiss %>%
pivot_wider(names_from = data_type, values_from = value)
head(covid19swiss_wide)
#> # A tibble: 6 x 13
#> date location location_type location_code location_code_type total_tested total_confirmed new_hosp current_hosp current_icu current_vent total_recovered total_death
#> <date> <chr> <chr> <chr> <chr> <int> <int> <int> <int> <int> <int> <int> <int>
#> 1 2020-02-25 GE Canton of Switzerland CH.GE gn_a1_code 72 0 NA 0 0 0 NA NA
#> 2 2020-02-25 TI Canton of Switzerland CH.TI gn_a1_code NA 1 NA NA NA NA NA NA
#> 3 2020-02-26 GE Canton of Switzerland CH.GE gn_a1_code 178 1 NA 1 0 0 NA NA
#> 4 2020-02-26 TI Canton of Switzerland CH.TI gn_a1_code NA NA NA NA NA NA NA NA
#> 5 2020-02-27 BS Canton of Switzerland CH.BS gn_a1_code NA 1 NA NA NA NA NA NA
#> 6 2020-02-27 FL Principality of Liechtenstein <NA> gn_a1_code 3 NA NA NA NA NA NA NA
The data is collected from multiple resources on the canton level, and
not necessarily each data resource provides the same field. Therefore,
some fields, such as total recovered or total tested may not be
available at this point for some cantons and are marked as missing
values (i.e., NA
).
Please submit issues and pull requests with any package improvements!
Please note that the ‘covid19swiss’ project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.