Skip to contents

The read_sav_gesis() function is a wrapper with DDIwR::convert() with the following modifications:

ZA5933 <- read_sav_gesis(file = system.file("extdata", "ZA5933_sample.sav", 
                                            package = "eurobarometer"))
  • The original, labelled survey variables are stored as declared, which has many advantages compared to the labelled class used by haven.
  • The study-level metadata is added as metadata to the data.frame with dataset::dublincore_add.
  • A truly unique identifier is added to the dataset. GESIS’s uniqid identifier is designed to be unique within one wave of Eurobarometer surveys. To avoid identification duplication, retroharmonize adds an id to each row.

Advantages of declared

The use of declared makes type conversions (and recoding, relabelling) easier.

ZA5933_sample$d25_num
#>  [1] 2 1 3 3 2 2 1 2 1 2 1 3
ZA5933_sample$d25_chr
#>  [1] "Small or middle sized town" "Rural area or village"     
#>  [3] "Large town"                 "Large town"                
#>  [5] "Small or middle sized town" "Small or middle sized town"
#>  [7] "Rural area or village"      "Small or middle sized town"
#>  [9] "Rural area or village"      "Small or middle sized town"
#> [11] "Rural area or village"      "Large town"

Advantages of dataset

The use of dataset helps to retain dataset-level metadata, which is critically important when we will combine datasets of different Eurobarometer survey waves, or make other interventions in the various stages of the survey lifecycle.

library(dataset)
#> 
#> Attaching package: 'dataset'
#> The following object is masked from 'package:base':
#> 
#>     as.data.frame
ZA5933_sample
#> Eurobarometer 82.4 (November-December 2014) (subset) (subset) [10.4232/1.13044] 
#> Published by GESIS
#>      uniqid d25 d25_num                    d25_chr
#> 1  46001088   2       2 Small or middle sized town
#> 2  42000703   1       1      Rural area or village
#> 3  32000989   3       3                 Large town
#> 4  12001054   3       3                 Large town
#> 5  35000877   2       2 Small or middle sized town
#> 6  40002682   2       2 Small or middle sized town
#> 7   7001327   1       1      Rural area or village
#> 8  36003657   2       2 Small or middle sized town
#> 9  35001629   1       1      Rural area or village
#> 10 22086838   2       2 Small or middle sized town
#> 
#> ... 2 further observations.
attributes(ZA5933_sample)
#> $names
#> [1] "uniqid"  "d25"     "d25_num" "d25_chr"
#> 
#> $row.names
#>  [1]  1  2  3  4  5  6  7  8  9 10 11 12
#> 
#> $class
#> [1] "dataset"    "data.frame"
#> 
#> $Title
#> $Title$Title
#> [1] "Eurobarometer 82.4 (November-December 2014) (subset) (subset)"
#> 
#> 
#> $Identifier
#> $Identifier$doi
#> [1] "10.4232/1.13044"
#> 
#> 
#> $Publisher
#> [1] "GESIS"
#> 
#> $Type
#> $Type$resourceType
#> [1] "DCMITYPE:Dataset"
#> 
#> $Type$resourceTypeGeneral
#> [1] "Dataset"
#> 
#> 
#> $Description
#> [1] NA
#> 
#> $Size
#> [1] "5.21 kB [5.09 KiB]"
#> 
#> $Date
#> [1] "2022-12-17"