read_dhs_flat.RdThis function reads a DHS recode dataset from the zipped flat file dataset.
read_dhs_flat(zfile, all_lower = TRUE, meta_source = NULL)
| zfile | Path to `.zip` file containing flat file dataset, usually ending in filename `XXXXXXFL.zip` |
|---|---|
| all_lower | Logical indicating whether all value labels should be lower case. Default to `TRUE`. |
| meta_source | character string indicating metadata source file for data
dictionary. Default |
A data frame. Value labels for each variable are stored as the `labelled` class from `haven`.
For more information on the DHS filetypes and contents of distributed dataset .ZIP files, see https://dhsprogram.com/data/File-Types-and-Names.cfm#CP_JUMP_10334.
mrfl_zip <- tempfile() download.file( paste0( "https://dhsprogram.com/customcf/legacy/data/sample_download_dataset.cfm?", "Filename=ZZMR61FL.ZIP&Tp=1&Ctry_Code=zz&survey_id=0&doctype=dhs"), mrfl_zip,mode="wb" ) mr <- rdhs:::read_dhs_flat(mrfl_zip) attr(mr$mv213, "label")#> [1] "Partner currently pregnant"#> [1] "haven_labelled"#> <Labelled integer>: Partner currently pregnant #> [1] NA 0 0 NA 0 NA #> #> Labels: #> value label #> 0 no #> 1 yes #> 8 unsure #> 9 missing#> #> 0 1 8 9 #> 1766 239 57 13#> #> no yes unsure missing #> 1766 239 57 13