Learn R Programming

healthbR (version 0.2.0)

pns_dictionary: Download PNS variable dictionary

Description

Downloads and returns the variable dictionary for PNS microdata. The dictionary is cached locally to avoid repeated downloads.

Usage

pns_dictionary(year = 2019, cache_dir = NULL, refresh = FALSE)

Value

A tibble with variable definitions.

Arguments

year

Numeric. Year to get dictionary for (2013 or 2019). Default is 2019.

cache_dir

Character. Directory for caching downloaded files. Default uses tools::R_user_dir("healthbR", "cache").

refresh

Logical. If TRUE, re-download even if file exists in cache. Default is FALSE.

Data source

Dictionaries are downloaded from the IBGE FTP server: https://ftp.ibge.gov.br/PNS/

Details

The dictionary includes variable names, labels, and response categories for the PNS microdata. This is useful for understanding the structure of the data returned by pns_data.

Examples

Run this code
if (FALSE) { # interactive()
# get dictionary for 2019
dict <- pns_dictionary(year = 2019, cache_dir = tempdir())

# get dictionary for 2013
dict_2013 <- pns_dictionary(year = 2013, cache_dir = tempdir())
}

Run the code above in your browser using DataLab