get_pns {PNSIBGE} | R Documentation |
Download, label, deflate and create survey design object for PNS microdata
Description
Core function of package. With this function only, the user can download a PNS microdata from a year and get a sample design object ready to use with survey
package functions.
Usage
get_pns(
year,
selected = FALSE,
anthropometry = FALSE,
vars = NULL,
labels = TRUE,
deflator = TRUE,
design = TRUE,
reload = TRUE,
curlopts = list(),
savedir = tempdir()
)
Arguments
year |
The year of the data to be downloaded. Must be a number equal to 2013 or 2019. Vector not accepted. |
selected |
Logical value. If |
anthropometry |
Logical value. If |
vars |
Vector of variable names to be kept for analysis. Default is to keep all variables. |
labels |
Logical value. If |
deflator |
Logical value. If |
design |
Logical value. If |
reload |
Logical value. If |
curlopts |
A named list object identifying the curl options for the handle when using functions from |
savedir |
Directory to save the downloaded data. Default is to use a temporary directory. |
Value
An object of class survey.design
or svyrep.design
with the data from PNS and its sample design, or a tibble with selected variables of the microdata, including the necessary survey design ones.
Note
For more information, visit the survey official website <https://www.ibge.gov.br/estatisticas/sociais/saude/9160-pesquisa-nacional-de-saude.html?=&t=o-que-e> and consult the other functions of this package, described below.
See Also
read_pns for reading PNS microdata.
pns_labeller for labeling categorical variables from PNS microdata.
pns_deflator for adding deflator variables to PNS microdata.
pns_design for creating PNS survey design object.
pns_example for getting the path of the PNS toy example files.
Examples
pns.svy <- get_pns(year=2019, selected=FALSE, anthropometry=FALSE, vars=c("J007","J009"),
labels=TRUE, deflator=TRUE, design=TRUE,
reload=TRUE, curlopts=list(), savedir=tempdir())
# Calculating proportion of people diagnosed with chronic diseases
if (!is.null(pns.svy)) survey::svymean(x=~J007, design=pns.svy, na.rm=TRUE)
pns.svy2 <- get_pns(year=2019, selected=TRUE, anthropometry=FALSE, vars=c("N001","N00101"),
labels=TRUE, deflator=TRUE, design=TRUE,
reload=TRUE, curlopts=list(), savedir=tempdir())
# Calculating proportion of people's self-rated health
if (!is.null(pns.svy2)) survey::svymean(x=~N001, design=pns.svy2, na.rm=TRUE)
pns.svy3 <- get_pns(year=2019, selected=FALSE, anthropometry=TRUE, vars=c("W00101","W00201"),
labels=TRUE, deflator=TRUE, design=TRUE,
reload=TRUE, curlopts=list(), savedir=tempdir())
# Calculating the average weight of people
if (!is.null(pns.svy3)) survey::svymean(x=~W00101, design=pns.svy3, na.rm=TRUE)