-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathREADME.Rmd
More file actions
110 lines (69 loc) · 3.82 KB
/
Copy pathREADME.Rmd
File metadata and controls
110 lines (69 loc) · 3.82 KB
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
---
output: github_document
---
# contactsurveys <img src="man/figures/logo.png" align="right" height="139" alt="contactsurveys website" />
<!-- badges: start -->
[](https://github.com/epiforecasts/contactsurveys/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/epiforecasts/contactsurveys)
<!-- badges: end -->
`contactsurveys` is an `R` package to download contact survey data, which can be used to derive social mixing matrices (see, for example, the [socialmixr](https://github.com/epiforecasts/socialmixr) package). This code was initially in the socialmixr package, but the code for downloading surveys has been moved into this package.
# Installation
The development version can be installed using `remotes`
```r
remotes::install_github("epiforecasts/contactsurveys")
```
# Example usage
```{r setup}
library(contactsurveys)
```
`contactsurveys` provides access to all surveys in the [Social contact data](https://zenodo.org/communities/social_contact_data) community on [Zenodo](https://zenodo.org).
## Listing surveys
The available surveys can be listed (if an internet connection is available) with `list_surveys()`
```{r}
social_contact_surveys <- list_surveys(verbose = FALSE)
dim(social_contact_surveys)
head(social_contact_surveys)
```
By default, the survey data from `list_surveys()` is effectively cached, so it will run very quickly the next time you run it. See `?list_surveys()` for more detail.
## Downloading surveys
Surveys can be downloaded using `download_survey()`. This will get the relevant data of a survey given its Zenodo DOI (as returned by `list_surveys()`).
```{r, results='hide'}
polymod_doi <- "https://doi.org/10.5281/zenodo.3874557"
polymod_survey_files <- download_survey(polymod_doi, verbose = FALSE)
```
## Getting citations
A reference for any given survey can be obtained by passing a DOI to `get_citation()`:
```{r}
get_citation(polymod_doi, verbose = FALSE)
```
## Using contact matrices with socialmixr
You can then use the survey files downloaded with functions from [socialmixr](https://github.com/epiforecasts/socialmixr), `load_survey()` and `contact_matrix()`.
```{r}
library(socialmixr)
polymod_loaded <- load_survey(polymod_survey_files)
uk_contact_matrix <- contact_matrix(
polymod_loaded,
countries = "United Kingdom",
age_limits = c(0, 18, 65)
)
uk_contact_matrix
```
## Contributors
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
All contributions to this project are gratefully acknowledged using the [`allcontributors` package](https://github.com/ropensci/allcontributors) following the [allcontributors](https://allcontributors.org) specification. Contributions of any kind are welcome!
### Code
<a href="https://github.com/epiforecasts/contactsurveys/commits?author=njtierney">njtierney</a>,
<a href="https://github.com/epiforecasts/contactsurveys/commits?author=sbfnk">sbfnk</a>,
<a href="https://github.com/epiforecasts/contactsurveys/commits?author=Bisaloo">Bisaloo</a>,
<a href="https://github.com/epiforecasts/contactsurveys/commits?author=lwillem">lwillem</a>,
<a href="https://github.com/epiforecasts/contactsurveys/commits?author=Degoot-AM">Degoot-AM</a>,
<a href="https://github.com/epiforecasts/contactsurveys/commits?author=jarvisc1">jarvisc1</a>,
<a href="https://github.com/epiforecasts/contactsurveys/commits?author=alxsrobert">alxsrobert</a>
### Issues
<a href="https://github.com/epiforecasts/contactsurveys/issues?q=is%3Aissue+commenter%3ALLucchini">LLucchini</a>
<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->