stata .dta format:
# an example of reading a stata dta file (note we need the haven:: package)
library("haven")
election_data <- read_dta("datasets/election/bes_f2f_original_v3.0.dta")
# notice that objects read from stata maintain some of their
# idiosyncratic internal structure -- e.g. you can see the survey items
# "embedded" inside the header fields in the R Studio spreadsheet view
head(election_data, n=5)
## # A tibble: 5 x 476
## finalserialno serial wt_sel_wt wt_combined_main_capped wt_combined_main
## <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 10102 2915 0.568195 0.594137 0.594137
## 2 10104 2505 1.136390 1.188274 1.188274
## 3 10107 876 1.136390 0.970153 0.970153
## 4 10109 875 1.136390 0.996799 0.996799
## 5 10202 3034 1.136390 0.968325 0.968325
## # ... with 471 more variables: wt_combined_CSES <dbl>, A1 <chr>,
## # a02 <dbl+lbl>, a03 <dbl+lbl>, m02_1 <dbl+lbl>, m02_2 <dbl+lbl>,
## # m02_3 <dbl+lbl>, m02_4 <dbl+lbl>, m02_5 <dbl+lbl>, m02_6 <dbl+lbl>,
## # m02_7 <dbl+lbl>, b01 <dbl+lbl>, b02 <dbl+lbl>, B02_other <chr>,
## # b04 <dbl+lbl>, B04_other <chr>, b05 <dbl+lbl>, b06_01 <dbl+lbl>,
## # b06_02 <dbl+lbl>, b06_03 <dbl+lbl>, b06_04 <dbl+lbl>,
## # b06_05 <dbl+lbl>, b06_06 <dbl+lbl>, b06_07 <dbl+lbl>,
## # b06_08 <dbl+lbl>, b06_09 <dbl+lbl>, b06_10 <dbl+lbl>,
## # b06_11 <dbl+lbl>, b06_12 <dbl+lbl>, b06_13 <dbl+lbl>,
## # b06_14 <dbl+lbl>, b06_15 <dbl+lbl>, b06_16 <dbl+lbl>,
## # b06_17 <dbl+lbl>, b06_18 <dbl+lbl>, b06_19 <dbl+lbl>,
## # b06_20 <dbl+lbl>, b07 <dbl+lbl>, b08_01 <dbl+lbl>, b08_02 <dbl+lbl>,
## # b08_03 <dbl+lbl>, b08_04 <dbl+lbl>, b08_05 <dbl+lbl>,
## # b08_06 <dbl+lbl>, b08_07 <dbl+lbl>, b08_08 <dbl+lbl>, b09 <dbl+lbl>,
## # b10 <dbl+lbl>, b11 <dbl+lbl>, B11_other <chr>, b12_1 <dbl+lbl>,
## # b12_2 <dbl+lbl>, b12_3 <dbl+lbl>, b12_4 <dbl+lbl>, b12_5 <dbl+lbl>,
## # b12_6 <dbl+lbl>, b13_1 <dbl+lbl>, b13_2 <dbl+lbl>, b13_3 <dbl+lbl>,
## # b13_4 <dbl+lbl>, b13_5 <dbl+lbl>, b13_6 <dbl+lbl>, b14_01 <dbl+lbl>,
## # b14_02 <dbl+lbl>, b14_03 <dbl+lbl>, b14_04 <dbl+lbl>,
## # b14_05 <dbl+lbl>, b14_06 <dbl+lbl>, b14_07 <dbl+lbl>,
## # b15_01 <dbl+lbl>, b15_02 <dbl+lbl>, b15_03 <dbl+lbl>,
## # b15_04 <dbl+lbl>, b15_05 <dbl+lbl>, b15_06 <dbl+lbl>,
## # b15_07 <dbl+lbl>, b16_01 <dbl+lbl>, b16_02 <dbl+lbl>,
## # b16_03 <dbl+lbl>, b16_04 <dbl+lbl>, b16_05 <dbl+lbl>,
## # b16_06 <dbl+lbl>, b16_07 <dbl+lbl>, b17_01 <dbl+lbl>,
## # b17_02 <dbl+lbl>, b17_03 <dbl+lbl>, b17_04 <dbl+lbl>,
## # b17_05 <dbl+lbl>, b17_06 <dbl+lbl>, b17_07 <dbl+lbl>,
## # b18_01 <dbl+lbl>, b18_02 <dbl+lbl>, b18_03 <dbl+lbl>,
## # b18_04 <dbl+lbl>, b18_05 <dbl+lbl>, b18_06 <dbl+lbl>,
## # b18_07 <dbl+lbl>, c01 <dbl+lbl>, c02_1 <dbl+lbl>, c02_2 <dbl+lbl>, ...