read_dhs_flat {rdhs} | R Documentation |
This 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("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))