Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dataobservatory-eu/surveydataset

Repository of the surveydataset package
https://github.com/dataobservatory-eu/surveydataset

Last synced: 27 days ago
JSON representation

Repository of the surveydataset package

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# surveydataset

[![lifecycle](https://lifecycle.r-lib.org/articles/figures/lifecycle-experimental.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7013164.svg)](https://zenodo.org/record/7013164#.YwFmc3ZBzIU)
[![devel-version](https://img.shields.io/badge/devel%20version-0.1.0-blue.svg)](https://github.com/dataobservatory-eu/surveydataset)
[![dataobservatory](https://img.shields.io/badge/ecosystem-dataobservatory.eu-3EA135.svg)](https://dataobservatory.eu/)
[![Follow rOpenGov](https://img.shields.io/twitter/follow/ropengov.svg?style=social)](https://twitter.com/intent/follow?screen_name=ropengov)
[![Follow author](https://img.shields.io/twitter/follow/digitalmusicobs.svg?style=social)](https://twitter.com/intent/follow?screen_name=digitalmusicobs)
[![Codecov test coverage](https://codecov.io/gh/dataobservatory-eu/surveydataset/branch/master/graph/badge.svg)](https://app.codecov.io/gh/dataobservatory-eu/surveydataset?branch=master)
[![R-CMD-check](https://github.com/dataobservatory-eu/surveydataset/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/dataobservatory-eu/surveydataset/actions/workflows/R-CMD-check.yaml)
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/dataobservatory-eu/surveydataset?branch=master&svg=true)](https://ci.appveyor.com/project/dataobservatory-eu/surveydataset)

The goal of the 'surveydataset' package is to create special datasets for social sciences surveys that are easier to release, exchange and reuse. It builds on the [dataset](http://dataset.dataobservatory.eu/) package which creates data frames that have clear structural and referncial metadata to be used in statistical exchanges or placed in scientific repositories. The ‘surveydataset’ package extends this functionality with the pecularities of social sciences surveys, and offers a data frame like container to be used with [DDIwR](https://CRAN.R-project.org/package=DDIwR) for survey documentation and [retroharmonize](https://retroharmonize.dataobservatory.eu/) for the retrospective harmonization of survey datasets.

## Installation

You can install the development version of surveydataset like so:

``` r
remotes::install_github('dataobservatory-eu/surveydataset')
```

## Read in a file

```{r example, message=FALSE}
library(surveydataset)
require(haven)
path <- system.file("ZA5688_v6_sample.sav", package = "surveydataset")
survey_raw <- read_spss_declared(path)
```

We have created a wrapper around [haven::read_spss()](https://haven.tidyverse.org/reference/read_spss.html) and `declared::as_declared()` to read in surveys in a less ambigous format:

```{r declared}
summary(as.factor(survey_raw$d25))
summary(survey_raw$d25)
```

The `read_spss_declared()` imports SPSS survey data into a [tibble](https://CRAN.R-project.org/package=tible), and changes the [labelled](https://CRAN.R-project.org/package=labelled) vectors (variable columns) to [declared](https://CRAN.R-project.org/package=declared) columns.

## Remove constans

```{r reduce-survey}
small_survey <- survey_raw[, c(1:6, 7, 10:14, 33)] # Only to keep example easier to read
head(small_survey)
```

```{r}
my_survey <- survey(
small_survey,
Dimensions = c("isocntry", "d25"),
Measures = c("qb1_1","qb1_2", "qb1_3"),
Attributes = c("wextra", "caseid"),
Constants = c(1:5),
Identifier = small_survey$doi[1],
Label = as.character(as.factor(small_survey$survey[1])),
Title = "Eurobarometer 79.2 (Small Demo Sample)",
Publisher = "GESIS",
Issued = substr("6.0.0 (2016-08-05)", 8, 17),
Creator = person("GESIS"))

dataset::version(my_survey) <- small_survey$version[1]
```

```{r summarize}
summary(my_survey)
```
```{r}
my_attributes <- attributes(my_survey)
my_attributes$names <- my_attributes$row.names <- NULL;
my_attributes
```

```{r citation, eval=FALSE}
utils::toBibtex(dataset::bibentry_dataset(my_survey))
```

## Further work

The `surveydataset` package is in a very early stage of its development. For citations please refer to the current development version as:

```{r citepackage}
citation('surveydataset')
```

## Code of Conduct

Please note that the surveydataset project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.