knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)

surveyreader

The goal of surveyreader is to help your migration of real-life survey data from the raw data file to R. The functions help to make consistent R representations of GESIS Eurobarometer archive files and for importing SurveyMonkey xlsx outputs.

Installation

You can install surveyreader from github with:

# install.packages("devtools")
devtools::install_github("antaldaniel/surveyreader")

Rescaling and recoding

Rescale the standard Eurobarometer satisfaction variable(s) with variable labels Very satisfied, Fairly satisfied, Not very satisfied, Not at all satisfied.

You can export each variable from the SPSS labelled variable class into numeric, character or factor representation. For better programmatic handling all variable category levels will be changed in a way that simplifies the text, removes special characters, and connects words optionally with underscores.

Regardless of ordering in various GESIS files, the ordering and spelling will be always the same in R.

require(surveyreader)
rescale_satisfaction (column =
                        c("DK",
                          "Very satisfied",
                          "Fairly satisfied",
                          "Not very satisfied",
                          "Not at all satisfied"),
                      underscore = FALSE,
                      return_class = "character")

Regardless of the original coding in SPSS, the numeric representation will be always the same in R, and it will yield consistent and meaningful values with similar variables.

require(surveyreader)
#' Create numeric codes
 rescale_satisfaction (column =
                        c("DK",
                          "Very satisfied",
                          "Fairly satisfied",
                          "Not very satisfied",
                          "Not at all satisfied"),
                      return_class = "numeric")

The functions are designed to facilitate data integration among GESIS files and non-English standard survey files.

require(surveyreader)
code_gender(column = as.character (c("1-no", "1-nő",
                                      "NA", NA, "0")),
             female_id = "1", female_value = 1,
             na_id = "NA")

Metadata

So far about 20 GESIS files were analyzed in detail. Based on this the not yet shared code finds naming, spelling inconsistencies and recommends a package function that can consistently rescale the variable. This way you can create a trend file from variables that were asked at varoius times with the same questions.

For testing purposes, a very small subset of the ZA6863_v1-0-0.sav files was included in the package that you can recreate from the GESIS file with the following code.

require(surveyreader)
set.seed(2017)
gesis_small_sample <-  ZA6863 %>%
  dplyr::sample_n (., size = 120 ) %>%
  dplyr::select( uniqid, serialid, split, 
                 qa1a_2, qa1b_2, qb1_3, qb1_4 )

haven::write_sav ( data = gesis_small_sample, 
                   path = 'data-raw/gesis_small_sample.sav' )

The gesis_small_sample can be loaded as an SPSS file, but it is also exported to the package as an rda file.

You can review the survey questions, their GESIS representation, the rOpenSci friendly new names and their suggested rescaling for immediate, consistent use in R with exporting the metadata (not run here.) The suggestions based on the levels of the GESIS files are shown with the get_answer_options function.



antaldaniel/surveyreader documentation built on May 16, 2019, 2:29 a.m.