Type: | Package |
Title: | Downloading, Reading and Analyzing PNADC Microdata |
Version: | 0.7.5 |
Description: | Provides tools for downloading, reading and analyzing the Continuous National Household Sample Survey - PNADC, a household survey from Brazilian Institute of Geography and Statistics - IBGE. The data must be downloaded from the official website https://www.ibge.gov.br/. Further analysis must be made using package 'survey'. |
Depends: | R (≥ 3.2.0) |
Imports: | dplyr, httr, magrittr, projmgr, RCurl, readr, readxl, survey, tibble, timeDate, utils |
Suggests: | convey, SIPDIBGE, srvyr |
License: | GPL-3 |
Encoding: | UTF-8 |
RoxygenNote: | 7.1.2 |
NeedsCompilation: | no |
Author: | Douglas Braga [aut], Gabriel Assuncao [aut, cre], Luna Hidalgo [ctb], Viviane Quintaes [ctb] |
Maintainer: | Gabriel Assuncao <pacotesipd@ibge.gov.br> |
BugReports: | https://github.com/Gabriel-Assuncao/PNADcIBGE/issues |
Packaged: | 2024-02-01 14:09:08 UTC; gabriel.assuncao |
Repository: | CRAN |
Date/Publication: | 2024-02-01 15:40:06 UTC |
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,
curlopts = list(),
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 |
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 |
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 |
selected |
Logical value. If |
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 |
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 |
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 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, curlopts=list(), 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, curlopts=list(), 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, curlopts=list(), 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)
Add deflator variables to PNADC microdata
Description
This function adds deflator variables to PNADC microdata. For deflation of income variables, the documentation provided through the following addresses must be used:
Quarter - https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_continua/Trimestral/Microdados/Documentacao/PNADcIBGE_Deflator_Trimestral.pdf.
Annual per Interview - https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_continua/Anual/Microdados/Visita/Documentacao_Geral/PNADcIBGE_Deflator_Anual_Visita.pdf.
Annual per Topic - https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_continua/Anual/Microdados/Trimestre/Documentacao_Geral/PNADcIBGE_Deflator_Anual_Trimestre.pdf.
Usage
pnadc_deflator(data_pnadc, deflator.file)
Arguments
data_pnadc |
A tibble of PNADC microdata read with |
deflator.file |
The deflator file for selected survey available on official website: |
Value
A tibble with the data provided from PNADC survey and the deflator variables added for use.
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
get_pnadc for downloading, labeling, deflating and creating survey design object for PNADC microdata.
read_pnadc for reading PNADC microdata.
pnadc_labeller for labeling categorical variables from PNADC microdata.
pnadc_design for creating PNADC survey design object.
pnadc_example for getting the path of the quarter PNADC toy example files.
Examples
# Using data read from disk
input_path <- pnadc_example(path="input_example.txt")
data_path <- pnadc_example(path="exampledata.txt")
dictionary.path <- pnadc_example(path="dictionaryexample.xls")
deflator.path <- pnadc_example(path="deflatorexample.xls")
pnadc.df <- read_pnadc(microdata=data_path, input_txt=input_path, vars=c("VD4001","VD4002"))
pnadc.df <- pnadc_labeller(data_pnadc=pnadc.df, dictionary.file=dictionary.path)
pnadc.df <- pnadc_deflator(data_pnadc=pnadc.df, deflator.file=deflator.path)
# Downloading data
pnadc.df2 <- get_pnadc(year=2017, quarter=4, selected=FALSE, vars=c("VD4001","VD4002"),
defyear=2017, defperiod=4, labels=TRUE, deflator=FALSE, design=FALSE,
reload=TRUE, curlopts=list(), savedir=tempdir())
deflator.path2 <- pnadc_example(path="deflatorexample.xls")
pnadc.df2 <- pnadc_deflator(data_pnadc=pnadc.df2, deflator.file=deflator.path2)
Create PNADC survey object with its sample design
Description
This function creates PNADC survey object with its sample design for analysis using survey
package functions.
Usage
pnadc_design(data_pnadc)
Arguments
data_pnadc |
A tibble of PNADC microdata read with |
Value
An object of class survey.design
or svyrep.design
with the data from PNADC and its sample design.
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
get_pnadc for downloading, labeling, deflating and creating survey design object for PNADC microdata.
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_example for getting the path of the quarter PNADC toy example files.
Examples
# Using data read from disk
input_path <- pnadc_example(path="input_example.txt")
data_path <- pnadc_example(path="exampledata.txt")
dictionary.path <- pnadc_example(path="dictionaryexample.xls")
deflator.path <- pnadc_example(path="deflatorexample.xls")
pnadc.df <- read_pnadc(microdata=data_path, input_txt=input_path, vars=c("VD4001","VD4002"))
pnadc.df <- pnadc_labeller(data_pnadc=pnadc.df, dictionary.file=dictionary.path)
pnadc.df <- pnadc_deflator(data_pnadc=pnadc.df, deflator.file=deflator.path)
pnadc.svy <- pnadc_design(data_pnadc=pnadc.df)
# Calculating proportion of employed and unemployed people
if (!is.null(pnadc.svy)) survey::svymean(x=~VD4002, design=pnadc.svy, na.rm=TRUE)
# Downloading data
pnadc.df2 <- get_pnadc(year=2017, quarter=4, selected=FALSE, vars=c("VD4001","VD4002"),
defyear=2017, defperiod=4, labels=TRUE, deflator=TRUE, design=FALSE,
reload=TRUE, curlopts=list(), savedir=tempdir())
pnadc.svy2 <- pnadc_design(data_pnadc=pnadc.df2)
# Calculating proportion of employed and unemployed people
if (!is.null(pnadc.svy2)) survey::svymean(x=~VD4002, design=pnadc.svy2, na.rm=TRUE)
Get the path of the quarter PNADC toy example files
Description
This function provides the path of the microdata from quarter 4 of year 2017 of the PNADC toy example files, loaded with this package.
Usage
pnadc_example(path = NULL)
Arguments
path |
Name of file. If |
Value
A vector with names of all the available quarter PNADC toy example files or the path for specific requested quarter PNADC toy example file.
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
get_pnadc for downloading, labeling, deflating and creating survey design object for PNADC microdata.
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.
Examples
pnadc_example()
pnadc_example(path="exampledata.txt")
pnadc_example(path="input_example.txt")
pnadc_example(path="dictionaryexample.xls")
pnadc_example(path="deflatorexample.xls")
Label categorical variables from PNADC microdata
Description
This function labels categorical variables from PNADC microdata.
Usage
pnadc_labeller(data_pnadc, dictionary.file)
Arguments
data_pnadc |
A tibble of PNADC microdata read with |
dictionary.file |
The dictionary file for selected survey available on official website: |
Value
A tibble with the data provided from PNADC survey and its categorical variables as factors with related labels.
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
get_pnadc for downloading, labeling, deflating and creating survey design object for PNADC microdata.
read_pnadc for reading 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
# Using data read from disk
input_path <- pnadc_example(path="input_example.txt")
data_path <- pnadc_example(path="exampledata.txt")
dictionary.path <- pnadc_example(path="dictionaryexample.xls")
pnadc.df <- read_pnadc(microdata=data_path, input_txt=input_path, vars=c("VD4001","VD4002"))
pnadc.df <- pnadc_labeller(data_pnadc=pnadc.df, dictionary.file=dictionary.path)
# Downloading data
pnadc.df2 <- get_pnadc(year=2017, quarter=4, selected=FALSE, vars=c("VD4001","VD4002"),
defyear=2017, defperiod=4, labels=FALSE, deflator=FALSE, design=FALSE,
reload=TRUE, curlopts=list(), savedir=tempdir())
dictionary.path2 <- pnadc_example(path="dictionaryexample.xls")
pnadc.df2 <- pnadc_labeller(data_pnadc=pnadc.df2, dictionary.file=dictionary.path2)
Read PNADC microdata
Description
This function reads PNADC microdata.
Usage
read_pnadc(microdata, input_txt, vars = NULL)
Arguments
microdata |
A text file containing microdata from PNADC survey, available on official website: |
input_txt |
A text file, related to the microdata, containing the input script for SAS, available on official website: |
vars |
Vector of variable names to be kept for analysis. Default is to keep all variables. |
Value
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
get_pnadc for downloading, labeling, deflating and creating survey design object for 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
input_path <- pnadc_example(path="input_example.txt")
data_path <- pnadc_example(path="exampledata.txt")
pnadc.df <- read_pnadc(microdata=data_path, input_txt=input_path, vars=c("VD4001","VD4002"))