read_dhs_flat: Read DHS flat file data set

View source: R/read_dhs_flat.R

read_dhs_flatR 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 NULL first tried to use .DCF and then .SPS if not found.

Value

A data frame. Value labels for each variable are stored as the 'labelled' class from 'haven'.

See Also

labelled, read_dhs_dta.

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))


OJWatson/rdhs documentation built on April 4, 2024, 10:46 a.m.