get_pnadc: Download, label, deflate and create survey design object for...

View source: R/get_pnadc.R

get_pnadcR Documentation

Download, label, deflate and create survey design object for PNADC microdata

Description

Core function of package. With this function only, the user can download a PNADC microdata from a year or quarter and get a sample design object ready to use with survey package functions.

Usage

get_pnadc(
  year,
  quarter = NULL,
  interview = NULL,
  topic = NULL,
  selected = FALSE,
  vars = NULL,
  defyear = NULL,
  defperiod = NULL,
  labels = TRUE,
  deflator = TRUE,
  design = TRUE,
  reload = TRUE,
  savedir = tempdir()
)

Arguments

year

The year of the data to be downloaded. Must be a number between 2012 and current year. Vector not accepted.

quarter

The quarter of the year of the data to be downloaded. Must be number from 1 to 4. Vector not accepted. If NULL, interview or topic number must be provided.

interview

The interview number of the data to be downloaded. Must be number from 1 to 5. Vector not accepted. Using this option will get annual per interview data. If NULL, quarter or topic number must be provided.

topic

The quarter related to the topic of the data to be downloaded. Must be number from 1 to 4. Vector not accepted. Using this option will get annual per topic data. If NULL, quarter or interview number must be provided.

selected

Logical value. If TRUE, the specific questionnaire for selected resident will be used. If FALSE, the basic questionnaire for household and residents will be used. For more information about these supplemental topics, please check the survey official website.

vars

Vector of variable names to be kept for analysis. Default is to keep all variables.

defyear

The year of the deflator data to be downloaded for annual microdata. Must be a number between 2017 and the last available year. Vector not accepted. If NULL, the deflator year will be defined as the last year available for interview microdata, or as equal to year for topic microdata. When quarter is defined, this argument will be ignored. This argument will be used only if deflator was set as TRUE.

defperiod

The quarter period of the deflator data to be downloaded for annual per topic microdata. Must be number from 1 to 4. Vector not accepted. If NULL, the deflator period will be defined as equal to topic. When quarter or interview is defined, this argument will be ignored. This argument will be used only if deflator was set as TRUE.

labels

Logical value. If TRUE, categorical variables will presented as factors with labels corresponding to the survey's dictionary.

deflator

Logical value. If TRUE, deflator variables will be available for use in the microdata.

design

Logical value. If TRUE, will return an object of class survey.design or svyrep.design. It is strongly recommended to keep this parameter as TRUE for further analysis. If FALSE, only the microdata will be returned.

reload

Logical value. If TRUE, will re-download the files even if they already exist in the save directory. If FALSE, will be checked if the files already exist in the save directory and the download will not be performed repeatedly.

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 PNADC 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/trabalho/9171-pesquisa-nacional-por-amostra-de-domicilios-continua-mensal.html?=&t=o-que-e> and consult the other functions of this package, described below.

See Also

read_pnadc for reading PNADC microdata.
pnadc_labeller for labeling categorical variables from PNADC microdata.
pnadc_deflator for adding deflator variables to PNADC microdata.
pnadc_design for creating PNADC survey design object.
pnadc_example for getting the path of the quarter PNADC toy example files.

Examples


pnadc.svy <- get_pnadc(year=2017, quarter=4, selected=FALSE, vars=c("VD4001","VD4002"),
                       defyear=2017, defperiod=4, labels=TRUE, deflator=TRUE, design=TRUE,
                       reload=TRUE, savedir=tempdir())
# Calculating proportion of employed and unemployed people
if (!is.null(pnadc.svy)) survey::svymean(x=~VD4002, design=pnadc.svy, na.rm=TRUE)
pnadc.svy2 <- get_pnadc(year=2017, interview=5, selected=FALSE, vars=c("V4112","V4121B"),
                        defyear=2017, defperiod=4, labels=TRUE, deflator=TRUE, design=TRUE,
                        reload=TRUE, savedir=tempdir())
# Calculating average hours dedicated to the care of people or household chores
if (!is.null(pnadc.svy2)) survey::svymean(x=~V4121B, design=pnadc.svy2, na.rm=TRUE)
pnadc.svy3 <- get_pnadc(year=2017, topic=4, selected=FALSE, vars=c("S07006","S07007"),
                        defyear=2017, defperiod=4, labels=TRUE, deflator=TRUE, design=TRUE,
                        reload=TRUE, savedir=tempdir())
# Calculating proportion of cell phone for personal use with internet access
if (!is.null(pnadc.svy3)) survey::svymean(x=~S07007, design=pnadc.svy3, na.rm=TRUE)

PNADcIBGE documentation built on Nov. 19, 2023, 1:09 a.m.