https://github.com/epiforecasts/contactsurveys
Download and access social contact data
https://github.com/epiforecasts/contactsurveys
Last synced: 9 months ago
JSON representation
Download and access social contact data
- Host: GitHub
- URL: https://github.com/epiforecasts/contactsurveys
- Owner: epiforecasts
- License: other
- Created: 2025-07-28T05:33:53.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-09-02T08:31:04.000Z (9 months ago)
- Last Synced: 2025-09-02T08:43:37.223Z (9 months ago)
- Language: R
- Homepage: http://epiforecasts.io/contactsurveys/
- Size: 1.33 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---
# contactsurveys
[](https://github.com/epiforecasts/contactsurveys/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/epiforecasts/contactsurveys)
`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}
polymod_doi <- "https://doi.org/10.5281/zenodo.3874557"
polymod_survey_files <- download_survey(polymod_doi, verbose = FALSE)
polymod_survey_files
```
## 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 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
sbfnk,
Bisaloo,
njtierney,
lwillem,
Degoot-AM,
jarvisc1,
alxsrobert
### Issues