Combining variables using case distinctions

The following makes use of the memisc package. You may need to install it from CRAN using the code install.packages("memisc") if you want to run this on your computer. (The package is already installed on the notebook container, however.)


library(memisc)
Loading required package: lattice

Loading required package: MASS


Attaching package: ‘memisc’


The following objects are masked from ‘package:stats’:

    contr.sum, contr.treatment, contrasts


The following object is masked from ‘package:base’:

    as.array


The following code works with example data from the 2017 German Longitudinal Election study: It code combines pre- and post-election variables in the to a single party-preference variable for the first (candidate) vote and the second (list) vote.

In order to run this notebook successfully, you have to download from GESIS and upload it to the virtual machine on which this notebook runs. To do this,

  1. pull down the “File” menu item and select “Open”
  2. An overview of the folder that contains the notebook opens.
  3. The folder view has a button labelled “Upload”. Use this to upload the file that you downloaded from the BES website. Its name should be ZA6802_en_v3-0-1.sav.

Note that the uploaded data will disappear, once you “Quit” the notebook (and the Jupyter instance).


gles2017.sav <- spss.system.file("ZA6802_en_v3-0-1.sav")
description(gles2017.sav[1:30])
File character set is 'UTF-8'.

Converting character set to the local 'utf-8'.

Warning message:
“10 variables have duplicated labels:
  vn2d, v10, vn141_i88, vn141_i08, vn150_i88, vn150_i08, vn158_i88,
  vn158_i08, vn163_i88, vn163_i08”

 study        'Study number (ZA-No.)'
 version      'GESIS Archive Version'
 doi          'Digital Object Identifier'
 year         'Survey year'
 field        'Field period'
 glescomp     'GLES component'
 survey       'Survey/wave'
 survey1      'Survey/wave (dummy)'
 lfdn         'Serial number (Cumulation)'
 vlfdn        'Serial number (Pre-election Cross Section)'
 nlfdn        'Serial number (Post-election Cross Section)'
 intnum       'Number of interviewer'
 welle        'Editing wave'
 intdate      'Date of interview'
 beginn       'Start time of interview'
 ende         'End time of interview'
 intdauer_ges 'Duration of interview in minutes'
 bula         'Federal state (Bundesland)'
 ostwest      'East/West (Berlin residents assigned to East)'
 ostwest2     'East/West (exact assignment of Berlin residents to East or West)'
 vnvpoint     'Virtual sample point'
 wahlkreis    'Electoral district'
 w_ow         'Weight, east/west'
 w_ipfges     'Weight of social/regional structure, total (with e/w weight)(MZ2017)'
 w_ipfost     'Weight of social/regional structure, east (MZ2017)'
 w_ipfwes     'Weight of social/regional structure, west (MZ2017))'
 vn_w_ipfges  'Weight of social/reg. structure, total (with e/w weight) cumulated'
 vn_w_ipfost  'Weight of social/reg. structure, east cumulated'
 vn_w_ipfwes  'Weight of social/reg. structure, west cumulated'
 vn1          'Gender'


gles2017.vote <- subset(gles2017.sav,
                           select=c(
                               survey = survey1,
                               pre.turnout.int = v10,
                               post.turnout = n10,
                               pre.voteint.first = v11ab,
                               pre.voteint.second = v11bb,
                               post.vote.first = n11ab,
                               post.vote.second = n11bb,
                               pre.postvote.first = v12ab,
                               pre.postvote.second = v12bb
                      ))
codebook(gles2017.vote)
================================================================================

   survey 'Survey/wave (dummy)'

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: nominal
   Missing values: -Inf - -1

   Values and labels         N Percent

   0   'Pre-election'     2179    50.8
   1   'Post-election'    2112    49.2

================================================================================

   pre.turnout.int 'Vote intention'

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: nominal
   Missing values: -Inf - -1

   Values and labels                           N Valid Total

   -98 M 'Don't know'                          7         0.2
   -97 M 'Not applicable'                     62         1.4
   -94 M 'Not in sampling frame'            2112        49.2
     1   'Certain to vote'                  1671  79.2  38.9
     2   'Likely to vote'                    151   7.2   3.5
     3   'Might vote'                         75   3.6   1.7
     4   'Not likely to vote'                 48   2.3   1.1
     5   'Certain not to vote'                70   3.3   1.6
     6   'Have already made a postal vote'    95   4.5   2.2
     7   'Not eligible to vote'                0   0.0   0.0

================================================================================

   post.turnout 'Turnout'

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: nominal
   Missing values: -Inf - -1

   Values and labels                 N Valid Total

   -99 M 'No answer'                 2         0.0
   -97 M 'Not applicable'           79         1.8
   -94 M 'Not in sampling frame'  2179        50.8
     1   'I did vote'             1826  89.9  42.6
     2   'I did not vote'          205  10.1   4.8

================================================================================

   pre.voteint.first 'Vote intention, first vote (version B)'

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: nominal
   Missing values: -Inf - -1

   Values and labels                    N Valid Total

   -99 M 'No answer'                   66         1.5
   -98 M 'Don't know'                 251         5.8
   -97 M 'Not applicable'             275         6.4
   -94 M 'Not in sampling frame'     2112        49.2
   -83 M 'Invalid vote'                14         0.3
     1   'CDU/CSU'                    693  44.1  16.2
     2   'CDU'                          0   0.0   0.0
     3   'CSU'                          0   0.0   0.0
     4   'SPD'                        383  24.3   8.9
     5   'FDP'                         90   5.7   2.1
     6   'GRUENE'                     133   8.5   3.1
     7   'DIE LINKE'                  143   9.1   3.3
   126   'BP'                           2   0.1   0.0
   149   'GRAUE'                        0   0.0   0.0
   151   'Die PARTEI'                   3   0.2   0.1
   152   'DIE VIOLETTEN'                1   0.1   0.0
   171   'FAMILIE'                      2   0.1   0.0
   180   'Freie Waehler'                4   0.3   0.1
   197   'KPD'                          0   0.0   0.0
   202   'MLPD'                         0   0.0   0.0
   206   'NPD'                          6   0.4   0.1
   207   'NSDAP'                        0   0.0   0.0
   209   'oedp'                         2   0.1   0.0
   214   'PBC'                          1   0.1   0.0
   215   'PIRATEN'                      4   0.3   0.1
   224   'RENTNER'                      1   0.1   0.0
   225   'REP'                          0   0.0   0.0
   226   'RRP'                          1   0.1   0.0
   229   'SED'                          0   0.0   0.0
   237   'Tierschutzpartei'             3   0.2   0.1
   241   'UDP'                          0   0.0   0.0
   249   'Volksabstimmung'              1   0.1   0.0
   304   'LDPD'                         0   0.0   0.0
   305   'DBD'                          0   0.0   0.0
   306   'DNVP'                         0   0.0   0.0
   307   'GB/BHE'                       0   0.0   0.0
   309   'NDPD'                         0   0.0   0.0
   322   'AfD'                         94   6.0   2.2
   323   'DIE RECHTE'                   0   0.0   0.0
   338   'BGE'                          2   0.1   0.0
   344   'V-Partei3'                    1   0.1   0.0
   348   'DM'                           0   0.0   0.0
   349   'DiB'                          0   0.0   0.0
   800   'Other'                        1   0.1   0.0
   801   'Other party'                  0   0.0   0.0
   802   'Individual candidate'         1   0.1   0.0
   803   'Voter community'              0   0.0   0.0
   808   'No party'                     1   0.1   0.0
   809   'All parties equally good'     0   0.0   0.0
   810   'With several parties'         0   0.0   0.0

================================================================================

   pre.voteint.second 'Vote intention, second vote (version B)'

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: nominal
   Missing values: -Inf - -1

   Values and labels                    N Valid Total

   -99 M 'No answer'                   63         1.5
   -98 M 'Don't know'                 236         5.5
   -97 M 'Not applicable'             275         6.4
   -94 M 'Not in sampling frame'     2112        49.2
   -83 M 'Invalid vote'                12         0.3
     1   'CDU/CSU'                    589  37.0  13.7
     2   'CDU'                          0   0.0   0.0
     3   'CSU'                          0   0.0   0.0
     4   'SPD'                        345  21.7   8.0
     5   'FDP'                        154   9.7   3.6
     6   'GRUENE'                     167  10.5   3.9
     7   'DIE LINKE'                  159  10.0   3.7
   126   'BP'                           2   0.1   0.0
   149   'GRAUE'                        0   0.0   0.0
   151   'Die PARTEI'                   9   0.6   0.2
   152   'DIE VIOLETTEN'                1   0.1   0.0
   171   'FAMILIE'                      2   0.1   0.0
   180   'Freie Waehler'                5   0.3   0.1
   197   'KPD'                          0   0.0   0.0
   202   'MLPD'                         0   0.0   0.0
   206   'NPD'                         11   0.7   0.3
   207   'NSDAP'                        0   0.0   0.0
   209   'oedp'                         2   0.1   0.0
   214   'PBC'                          1   0.1   0.0
   215   'PIRATEN'                     15   0.9   0.3
   224   'RENTNER'                      1   0.1   0.0
   225   'REP'                          0   0.0   0.0
   226   'RRP'                          1   0.1   0.0
   229   'SED'                          0   0.0   0.0
   237   'Tierschutzpartei'             5   0.3   0.1
   241   'UDP'                          0   0.0   0.0
   249   'Volksabstimmung'              1   0.1   0.0
   304   'LDPD'                         0   0.0   0.0
   305   'DBD'                          0   0.0   0.0
   306   'DNVP'                         0   0.0   0.0
   307   'GB/BHE'                       0   0.0   0.0
   309   'NDPD'                         0   0.0   0.0
   322   'AfD'                        116   7.3   2.7
   323   'DIE RECHTE'                   0   0.0   0.0
   338   'BGE'                          3   0.2   0.1
   344   'V-Partei3'                    0   0.0   0.0
   348   'DM'                           0   0.0   0.0
   349   'DiB'                          2   0.1   0.0
   800   'Other'                        1   0.1   0.0
   801   'Other party'                  0   0.0   0.0
   802   'Individual candidate'         0   0.0   0.0
   803   'Voter community'              0   0.0   0.0
   808   'No party'                     1   0.1   0.0
   809   'All parties equally good'     0   0.0   0.0
   810   'With several parties'         0   0.0   0.0

================================================================================

   post.vote.first 'Voting decision, first vote (version B)'

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: nominal
   Missing values: -Inf - -1

   Values and labels                    N Valid Total

   -99 M 'No answer'                  117         2.7
   -98 M 'Don't know'                  11         0.3
   -97 M 'Not applicable'             286         6.7
   -94 M 'Not in sampling frame'     2179        50.8
   -83 M 'Invalid vote'                11         0.3
     1   'CDU/CSU'                    594  35.2  13.8
     2   'CDU'                          0   0.0   0.0
     3   'CSU'                          0   0.0   0.0
     4   'SPD'                        425  25.2   9.9
     5   'FDP'                        136   8.1   3.2
     6   'GRUENE'                     163   9.7   3.8
     7   'DIE LINKE'                  167   9.9   3.9
   126   'BP'                           1   0.1   0.0
   149   'GRAUE'                        0   0.0   0.0
   151   'Die PARTEI'                  14   0.8   0.3
   152   'DIE VIOLETTEN'                0   0.0   0.0
   171   'FAMILIE'                      0   0.0   0.0
   180   'Freie Waehler'               14   0.8   0.3
   197   'KPD'                          0   0.0   0.0
   202   'MLPD'                         0   0.0   0.0
   206   'NPD'                          0   0.0   0.0
   207   'NSDAP'                        0   0.0   0.0
   209   'oedp'                         5   0.3   0.1
   214   'PBC'                          0   0.0   0.0
   215   'PIRATEN'                      7   0.4   0.2
   224   'RENTNER'                      0   0.0   0.0
   225   'REP'                          0   0.0   0.0
   226   'RRP'                          0   0.0   0.0
   229   'SED'                          0   0.0   0.0
   237   'Tierschutzpartei'             4   0.2   0.1
   241   'UDP'                          0   0.0   0.0
   249   'Volksabstimmung'              0   0.0   0.0
   304   'LDPD'                         0   0.0   0.0
   305   'DBD'                          1   0.1   0.0
   306   'DNVP'                         0   0.0   0.0
   307   'GB/BHE'                       0   0.0   0.0
   309   'NDPD'                         0   0.0   0.0
   322   'AfD'                        148   8.8   3.4
   323   'DIE RECHTE'                   0   0.0   0.0
   338   'BGE'                          0   0.0   0.0
   344   'V-Partei3'                    1   0.1   0.0
   348   'DM'                           0   0.0   0.0
   349   'DiB'                          0   0.0   0.0
   800   'Other'                        0   0.0   0.0
   801   'Other party'                  0   0.0   0.0
   802   'Individual candidate'         4   0.2   0.1
   803   'Voter community'              0   0.0   0.0
   808   'No party'                     0   0.0   0.0
   809   'All parties equally good'     0   0.0   0.0
   810   'With several parties'         0   0.0   0.0
         (unlab.val.)                   3   0.2   0.1

================================================================================

   post.vote.second 'Voting decision, second vote (version B)'

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: nominal
   Missing values: -Inf - -1

   Values and labels                    N Valid Total

   -99 M 'No answer'                  120         2.8
   -98 M 'Don't know'                   5         0.1
   -97 M 'Not applicable'             286         6.7
   -94 M 'Not in sampling frame'     2179        50.8
   -83 M 'Invalid vote'                11         0.3
     1   'CDU/CSU'                    504  29.8  11.7
     2   'CDU'                          0   0.0   0.0
     3   'CSU'                          0   0.0   0.0
     4   'SPD'                        338  20.0   7.9
     5   'FDP'                        200  11.8   4.7
     6   'GRUENE'                     225  13.3   5.2
     7   'DIE LINKE'                  188  11.1   4.4
   126   'BP'                           1   0.1   0.0
   149   'GRAUE'                        0   0.0   0.0
   151   'Die PARTEI'                  23   1.4   0.5
   152   'DIE VIOLETTEN'                0   0.0   0.0
   171   'FAMILIE'                      1   0.1   0.0
   180   'Freie Waehler'               17   1.0   0.4
   197   'KPD'                          1   0.1   0.0
   202   'MLPD'                         0   0.0   0.0
   206   'NPD'                          2   0.1   0.0
   207   'NSDAP'                        0   0.0   0.0
   209   'oedp'                         4   0.2   0.1
   214   'PBC'                          0   0.0   0.0
   215   'PIRATEN'                      8   0.5   0.2
   224   'RENTNER'                      1   0.1   0.0
   225   'REP'                          0   0.0   0.0
   226   'RRP'                          0   0.0   0.0
   229   'SED'                          0   0.0   0.0
   237   'Tierschutzpartei'             6   0.4   0.1
   241   'UDP'                          0   0.0   0.0
   249   'Volksabstimmung'              0   0.0   0.0
   304   'LDPD'                         0   0.0   0.0
   305   'DBD'                          0   0.0   0.0
   306   'DNVP'                         0   0.0   0.0
   307   'GB/BHE'                       0   0.0   0.0
   309   'NDPD'                         0   0.0   0.0
   322   'AfD'                        162   9.6   3.8
   323   'DIE RECHTE'                   0   0.0   0.0
   338   'BGE'                          2   0.1   0.0
   344   'V-Partei3'                    1   0.1   0.0
   348   'DM'                           0   0.0   0.0
   349   'DiB'                          2   0.1   0.0
   800   'Other'                        0   0.0   0.0
   801   'Other party'                  0   0.0   0.0
   802   'Individual candidate'         0   0.0   0.0
   803   'Voter community'              0   0.0   0.0
   808   'No party'                     0   0.0   0.0
   809   'All parties equally good'     0   0.0   0.0
   810   'With several parties'         0   0.0   0.0
         (unlab.val.)                   4   0.2   0.1

================================================================================

   pre.postvote.first 'Voting decision, absentee ballot, first vote (version
   B)'

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: nominal
   Missing values: -Inf - -1

   Values and labels                    N Valid Total

   -99 M 'No answer'                    5         0.1
   -98 M 'Don't know'                   1         0.0
   -97 M 'Not applicable'            2084        48.6
   -94 M 'Not in sampling frame'     2112        49.2
     1   'CDU/CSU'                     33  37.1   0.8
     2   'CDU'                          0   0.0   0.0
     3   'CSU'                          0   0.0   0.0
     4   'SPD'                         19  21.3   0.4
     5   'FDP'                          4   4.5   0.1
     6   'GRUENE'                      13  14.6   0.3
     7   'DIE LINKE'                   12  13.5   0.3
   126   'BP'                           0   0.0   0.0
   149   'GRAUE'                        0   0.0   0.0
   151   'Die PARTEI'                   1   1.1   0.0
   152   'DIE VIOLETTEN'                0   0.0   0.0
   171   'FAMILIE'                      0   0.0   0.0
   180   'Freie Waehler'                0   0.0   0.0
   197   'KPD'                          0   0.0   0.0
   202   'MLPD'                         0   0.0   0.0
   206   'NPD'                          1   1.1   0.0
   207   'NSDAP'                        0   0.0   0.0
   209   'oedp'                         1   1.1   0.0
   214   'PBC'                          1   1.1   0.0
   215   'PIRATEN'                      1   1.1   0.0
   224   'RENTNER'                      0   0.0   0.0
   225   'REP'                          0   0.0   0.0
   226   'RRP'                          0   0.0   0.0
   229   'SED'                          0   0.0   0.0
   237   'Tierschutzpartei'             0   0.0   0.0
   241   'UDP'                          0   0.0   0.0
   249   'Volksabstimmung'              0   0.0   0.0
   304   'LDPD'                         0   0.0   0.0
   305   'DBD'                          0   0.0   0.0
   306   'DNVP'                         0   0.0   0.0
   307   'GB/BHE'                       0   0.0   0.0
   309   'NDPD'                         0   0.0   0.0
   322   'AfD'                          3   3.4   0.1
   323   'DIE RECHTE'                   0   0.0   0.0
   338   'BGE'                          0   0.0   0.0
   344   'V-Partei3'                    0   0.0   0.0
   348   'DM'                           0   0.0   0.0
   349   'DiB'                          0   0.0   0.0
   800   'Other'                        0   0.0   0.0
   801   'Other party'                  0   0.0   0.0
   802   'Individual candidate'         0   0.0   0.0
   803   'Voter community'              0   0.0   0.0
   808   'No party'                     0   0.0   0.0
   809   'All parties equally good'     0   0.0   0.0
   810   'With several parties'         0   0.0   0.0

================================================================================

   pre.postvote.second 'Voting decision, absentee ballot, second vote (version
   B)'

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: nominal
   Missing values: -Inf - -1

   Values and labels                    N Valid Total

   -99 M 'No answer'                    5         0.1
   -98 M 'Don't know'                   1         0.0
   -97 M 'Not applicable'            2084        48.6
   -94 M 'Not in sampling frame'     2112        49.2
     1   'CDU/CSU'                     27  30.3   0.6
     2   'CDU'                          0   0.0   0.0
     3   'CSU'                          0   0.0   0.0
     4   'SPD'                         20  22.5   0.5
     5   'FDP'                          8   9.0   0.2
     6   'GRUENE'                      11  12.4   0.3
     7   'DIE LINKE'                   12  13.5   0.3
   126   'BP'                           0   0.0   0.0
   149   'GRAUE'                        0   0.0   0.0
   151   'Die PARTEI'                   1   1.1   0.0
   152   'DIE VIOLETTEN'                0   0.0   0.0
   171   'FAMILIE'                      0   0.0   0.0
   180   'Freie Waehler'                1   1.1   0.0
   197   'KPD'                          0   0.0   0.0
   202   'MLPD'                         0   0.0   0.0
   206   'NPD'                          1   1.1   0.0
   207   'NSDAP'                        0   0.0   0.0
   209   'oedp'                         1   1.1   0.0
   214   'PBC'                          1   1.1   0.0
   215   'PIRATEN'                      2   2.2   0.0
   224   'RENTNER'                      0   0.0   0.0
   225   'REP'                          0   0.0   0.0
   226   'RRP'                          0   0.0   0.0
   229   'SED'                          0   0.0   0.0
   237   'Tierschutzpartei'             1   1.1   0.0
   241   'UDP'                          0   0.0   0.0
   249   'Volksabstimmung'              0   0.0   0.0
   304   'LDPD'                         0   0.0   0.0
   305   'DBD'                          0   0.0   0.0
   306   'DNVP'                         0   0.0   0.0
   307   'GB/BHE'                       0   0.0   0.0
   309   'NDPD'                         0   0.0   0.0
   322   'AfD'                          3   3.4   0.1
   323   'DIE RECHTE'                   0   0.0   0.0
   338   'BGE'                          0   0.0   0.0
   344   'V-Partei3'                    0   0.0   0.0
   348   'DM'                           0   0.0   0.0
   349   'DiB'                          0   0.0   0.0
   800   'Other'                        0   0.0   0.0
   801   'Other party'                  0   0.0   0.0
   802   'Individual candidate'         0   0.0   0.0
   803   'Voter community'              0   0.0   0.0
   808   'No party'                     0   0.0   0.0
   809   'All parties equally good'     0   0.0   0.0
   810   'With several parties'         0   0.0   0.0


gles2017.vote <- within(gles2017.vote,{
  vote.first <- cases(
              survey == 0 & pre.turnout.int == 6 -> pre.postvote.first,
              survey == 0 & pre.turnout.int %in% 4:5 -> -85,
              survey == 0 & pre.turnout.int %in% 1:3 -> pre.voteint.first,
              survey == 1 & post.turnout ==1 -> post.vote.first,
              survey == 1 & post.turnout ==2 -> -85,
              TRUE -> -97
            )
  vote.second <- cases(
              survey == 0 & pre.turnout.int == 6 -> pre.postvote.second,
              survey == 0 & pre.turnout.int %in% 4:5 -> -85,
              survey == 0 & pre.turnout.int %in% 1:3 -> pre.voteint.second,
              survey == 1 & post.turnout ==1 -> post.vote.second,
              survey == 1 & post.turnout ==2 -> -85,
              TRUE -> -97
  )
  vote.first <- as.item(vote.first, labels = labels(pre.postvote.first))
  vote.second <- as.item(vote.second, labels = labels(pre.postvote.second))
  valid.range(vote.first) <- valid.range(vote.second) <- c(1,900)
})
Warning message in cases(pre.postvote.first <- survey == 0 & pre.turnout.int == :
“conditions are not mutually exclusive”
Warning message in cases(pre.postvote.second <- survey == 0 & pre.turnout.int == :
“conditions are not mutually exclusive”

codebook(gles2017.vote[c("vote.first","vote.second")])
================================================================================

   vote.first

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: nominal
   Valid range: 1 - 900

   Values and labels                    N Valid Total

   -99 M 'No answer'                  187         4.4
   -98 M 'Don't know'                 263         6.1
   -97 M 'Not applicable'             150         3.5
   -85 M 'No turn out'                323         7.5
   -83 M 'Invalid vote'                25         0.6
     1   'CDU/CSU'                   1318  39.4  30.7
     2   'CDU'                          0   0.0   0.0
     3   'CSU'                          0   0.0   0.0
     4   'SPD'                        826  24.7  19.2
     5   'FDP'                        230   6.9   5.4
     6   'GRUENE'                     309   9.2   7.2
     7   'DIE LINKE'                  320   9.6   7.5
   126   'BP'                           3   0.1   0.1
   149   'GRAUE'                        0   0.0   0.0
   151   'Die PARTEI'                  18   0.5   0.4
   152   'DIE VIOLETTEN'                1   0.0   0.0
   171   'FAMILIE'                      2   0.1   0.0
   180   'Freie Waehler'               18   0.5   0.4
   197   'KPD'                          0   0.0   0.0
   202   'MLPD'                         0   0.0   0.0
   206   'NPD'                          7   0.2   0.2
   207   'NSDAP'                        0   0.0   0.0
   209   'oedp'                         8   0.2   0.2
   214   'PBC'                          2   0.1   0.0
   215   'PIRATEN'                     12   0.4   0.3
   224   'RENTNER'                      1   0.0   0.0
   225   'REP'                          0   0.0   0.0
   226   'RRP'                          1   0.0   0.0
   229   'SED'                          0   0.0   0.0
   237   'Tierschutzpartei'             7   0.2   0.2
   241   'UDP'                          0   0.0   0.0
   249   'Volksabstimmung'              1   0.0   0.0
   304   'LDPD'                         0   0.0   0.0
   305   'DBD'                          1   0.0   0.0
   306   'DNVP'                         0   0.0   0.0
   307   'GB/BHE'                       0   0.0   0.0
   309   'NDPD'                         0   0.0   0.0
   322   'AfD'                        244   7.3   5.7
   323   'DIE RECHTE'                   0   0.0   0.0
   338   'BGE'                          2   0.1   0.0
   344   'V-Partei3'                    2   0.1   0.0
   348   'DM'                           0   0.0   0.0
   349   'DiB'                          0   0.0   0.0
   800   'Other'                        1   0.0   0.0
   801   'Other party'                  0   0.0   0.0
   802   'Individual candidate'         5   0.1   0.1
   803   'Voter community'              0   0.0   0.0
   808   'No party'                     1   0.0   0.0
   809   'All parties equally good'     0   0.0   0.0
   810   'With several parties'         0   0.0   0.0
         (unlab.val.)                   3   0.1   0.1

================================================================================

   vote.second

--------------------------------------------------------------------------------

   Storage mode: double
   Measurement: nominal
   Valid range: 1 - 900

   Values and labels                    N Valid Total

   -99 M 'No answer'                  187         4.4
   -98 M 'Don't know'                 240         5.6
   -97 M 'Not applicable'             150         3.5
   -85 M 'No turn out'                323         7.5
   -83 M 'Invalid vote'                23         0.5
     1   'CDU/CSU'                   1119  33.2  26.1
     2   'CDU'                          0   0.0   0.0
     3   'CSU'                          0   0.0   0.0
     4   'SPD'                        702  20.8  16.4
     5   'FDP'                        362  10.7   8.4
     6   'GRUENE'                     403  12.0   9.4
     7   'DIE LINKE'                  358  10.6   8.3
   126   'BP'                           3   0.1   0.1
   149   'GRAUE'                        0   0.0   0.0
   151   'Die PARTEI'                  33   1.0   0.8
   152   'DIE VIOLETTEN'                1   0.0   0.0
   171   'FAMILIE'                      3   0.1   0.1
   180   'Freie Waehler'               23   0.7   0.5
   197   'KPD'                          1   0.0   0.0
   202   'MLPD'                         0   0.0   0.0
   206   'NPD'                         14   0.4   0.3
   207   'NSDAP'                        0   0.0   0.0
   209   'oedp'                         7   0.2   0.2
   214   'PBC'                          2   0.1   0.0
   215   'PIRATEN'                     25   0.7   0.6
   224   'RENTNER'                      2   0.1   0.0
   225   'REP'                          0   0.0   0.0
   226   'RRP'                          1   0.0   0.0
   229   'SED'                          0   0.0   0.0
   237   'Tierschutzpartei'            12   0.4   0.3
   241   'UDP'                          0   0.0   0.0
   249   'Volksabstimmung'              1   0.0   0.0
   304   'LDPD'                         0   0.0   0.0
   305   'DBD'                          0   0.0   0.0
   306   'DNVP'                         0   0.0   0.0
   307   'GB/BHE'                       0   0.0   0.0
   309   'NDPD'                         0   0.0   0.0
   322   'AfD'                        280   8.3   6.5
   323   'DIE RECHTE'                   0   0.0   0.0
   338   'BGE'                          5   0.1   0.1
   344   'V-Partei3'                    1   0.0   0.0
   348   'DM'                           0   0.0   0.0
   349   'DiB'                          4   0.1   0.1
   800   'Other'                        1   0.0   0.0
   801   'Other party'                  0   0.0   0.0
   802   'Individual candidate'         0   0.0   0.0
   803   'Voter community'              0   0.0   0.0
   808   'No party'                     1   0.0   0.0
   809   'All parties equally good'     0   0.0   0.0
   810   'With several parties'         0   0.0   0.0
         (unlab.val.)                   4   0.1   0.1

Downloadable R script and interactive version

Explanation

The link with the “jupyterhub” icon directs you to an interactive Jupyter1 notebook, which runs inside a Docker container2. There are two variants of the interative notebook. One shuts down after 60 seconds and does not require a sign it. The other requires sign in using your ORCID3 credentials, yet shuts down only after 24 hours. (There is no guarantee that such a container persists that long, it may be shut down earlier for maintenance purposes.) After shutdown all data within the container will be reset, i.e. all files created by the user will be deleted.4

Above you see a rendered version of the Jupyter notebook.5

1

For more information about Jupyter see http://jupyter.org. The Jupyter notebooks make use of the IRKernel package.

2

For more information about Docker see https://docs.docker.com/. The container images were created with repo2docker, while containers are run with docker spawner.

3

ORCID is a free service for the authentication of researchers. It also allows to showcase publications and contributions to the academic community such as peer review.. See https://info.orcid.org/what-is-orcid/ for more information.

4

The Jupyter notebooks come with NO WARRANTY whatsoever. They are provided for educational and illustrative purposes only. Do not use them for production work.

5

The notebook is rendered with the help of the nbsphinx extension.