-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
96 lines (74 loc) · 2.58 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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# gdpm
<!-- badges: start -->
[](https://ci.appveyor.com/project/epix-project/gdpm)
[](https://travis-ci.org/epix-project/gdpm)
[](https://codecov.io/gh/epix-project/gdpm?branch=master)
<!-- badges: end -->
The goal of gdpm is to provide the data from the General Department of Preventive
Medicine ([GDPM](http://vncdc.gov.vn/en)) of Vietnam.
## Installation
You can install the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("epix-project/gdpm")
```
## Example
```{r}
library(gdpm)
```
The package contains epidemiological data in 29 epidemiological data frames, each data frame corresponding to one syndromic disease. For example, `chickenpox`:
```{r}
chickenpox <- getid(chickenpox)
head(chickenpox)
```
The data are expressed by the `incidence` or number of cases and `mortality` or the number of death per `province`, `month` and `year`.
See below, the section on the `getid` function, for an illustration of the specificity of this function.
The structure of the data frame is:
```{r}
str(chickenpox)
```
Note that time is coded by the 2 variables `year` and `month`. The latter is a factor in which the coding of the levels follows their chronological order:
```{r}
levels(chickenpox$month)
```
Head and tail of the data frame `chickenpox`:
```{r}
head(chickenpox)
tail(chickenpox)
```
## Exporting to EPIPOI
Below is a function that queries the GDPM data from a disease `x` (`"mumps"`,
`"measles"`, etc...) and exports the variable `var` (either `"incidence"` or
`"mortality"`) to an excel in a format compatible with
[EPIPOI](http://www.epipoi.info):
```{r eval = FALSE}
export2epipoi <- function(x, var = "incidence") {
require(gdpm)
require(dplyr)
require(tidyr)
require(openxlsx)
x %>%
getid_() %>%
select(year, month, province, starts_with(var)) %>%
mutate(month = as.integer(month)) %>%
arrange(year, month) %>%
spread(province, 4) %>%
write.xlsx(paste0(x, "_epipoi.xlsx"))
}
```
Its usage would be:
```{r eval = FALSE}
export2epipoi("mumps")
```