-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.Rmd
136 lines (85 loc) · 5.31 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
message=FALSE, warning=FALSE,
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# covid19swiss
<!-- badges: start -->
[![build](https://github.com/covid19r/covid19swiss/workflows/build/badge.svg?branch=master)](https://github.com/covid19r/covid19swiss/actions?query=workflow%3Abuild)
[![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/covid19swiss)](https://cran.r-project.org/package=covid19swiss)
[![lifecycle](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![GitHub commit](https://img.shields.io/github/last-commit/covid19r/covid19swiss)](https://github.com/covid19r/covid19swiss/commit/master)
<!-- badges: end -->
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 package is following the data structure of the [Covid19R project](https://covid19r.github.io/documentation/data-format-standard.html).
<img src="man/figures/swiss_map.png" width="100%" align="center"/></a>
The `covid19swiss` dataset includes the following fields:
* `date` - the timestamp of the case, a `Date` object
* `location` - the **Cantons of Switzerland** and **the Principality of Liechtenstein** (FL) abbreviation code
* `location_type` - description of the location, either **Canton of Switzerland** or **the Principality of echtenstein**
* `location_code` - a canton index code for merging geometry data from the rnaturalearth package, ailable only for Switzerland cantons
* `location_code_type` - the name of code in the **rnaturalearth** package for Switzerland map
* `data_type` - the type of case
* `value` - the number of cases corresponding to the `date` and `data_type` fields
Where the available `data_type` field includes the following cases:
* `tested_total` - cumulative number of tests performed as of the date
* `cases_total` - cumulative confirmed Covid-19 cases as of the current date
* `hosp_new` - new hospitalizations on the current date
* `hosp_current` - current number of hospitalized patients as of the current date
* `icu_current` - number of hospitalized patients in ICUs as of the current date
* `vent_current` - number of hospitalized patients requiring ventilation as of the current date
* `recovered_total` - cumulative number of patients recovered as of the current date
* `deaths_total` - cumulative deaths due to Covid-19 as of the current date
More information can be found the following vignettes:
* [Introduction to the covid19swiss Dataset](https://covid19r.github.io/covid19swiss/articles/intro_covid19swiss.html)
* [Updating the covid19swiss Dataset](https://covid19r.github.io/covid19swiss/articles/update_the_data.html)
* [Geospatial Visualization of Switzerland Cantons](https://covid19r.github.io/covid19swiss/articles/spatial_dataviz.html) (non CRAN vignette)
Data source: [Specialist Unit for Open Government Data Canton of Zurich
](https://www.zh.ch/de/politik-staat/opendata.html), raw data is available on the following [repository](https://github.com/openZH/covid_19). Special thanks for all the people that collaborate and contribute to pull the data from multiple sources and make this data available!
## Installation
You can install the released version of covid19swiss from CRAN with:
``` r
install.packages("covid19swiss")
```
Or, install the most recent version from [GitHub](https://github.com/Covid19R/covid19swiss) with:
``` r
# install.packages("devtools")
devtools::install_github("Covid19R/covid19swiss")
```
## Data refresh
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:
``` r
library(covid19swiss)
update_swiss_data()
```
More information about updating the data is available on this [vignette](https://covid19r.github.io/covid19swiss/articles/update_the_data.html)
**Note:** must restart the R session after using the `update_swiss_data` function in order to have the updates available
## Usage
```{r }
data(covid19swiss)
head(covid19swiss)
```
### Wide format
```{r}
library(tidyr)
covid19swiss_wide <- covid19swiss %>%
pivot_wider(names_from = data_type, values_from = value)
head(covid19swiss_wide)
```
## Missing values
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`).
## Contributing
Please submit [issues](https://github.com/Covid19R/covid19swiss/issues)
and [pull requests](https://github.com/Covid19R/covid19swiss/pulls)
with any package improvements\!
Please note that the ‘covid19swiss’ project is released with a
[Contributor Code of Conduct](https://github.com/Covid19R/covid19swiss/blob/master/CODE_OF_CONDUCT.md). By contributing to
this project, you agree to abide by its terms.