read_dhs_flat {rdhs} | R Documentation |
Read DHS flat file data set
Description
This function reads a DHS recode dataset from the zipped flat file dataset.
Usage
read_dhs_flat(zfile, all_lower = TRUE, meta_source = NULL)
Arguments
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 |
Value
A data frame. Value labels for each variable are stored as the 'labelled' class from 'haven'.
See Also
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.
Examples
mrfl_zip <- tempfile()
download.file("https://dhsprogram.com/data/model_data/dhs/zzmr61fl.zip",
mrfl_zip,mode="wb")
mr <- rdhs:::read_dhs_flat(mrfl_zip)
attr(mr$mv213, "label")
class(mr$mv213)
head(mr$mv213)
table(mr$mv213)
table(haven::as_factor(mr$mv213))
[Package rdhs version 0.8.1 Index]