Title: | Downloading, Reading and Analyzing PNAD COVID19 Microdata |
---|---|
Description: | Provides tools for downloading, reading and analyzing the COVID19 National Household Sample Survey - PNAD COVID19, 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'. |
Authors: | Gabriel Assuncao [aut, cre], Luna Hidalgo [aut], Douglas Braga [ctb], Viviane Quintaes [ctb] |
Maintainer: | Gabriel Assuncao <[email protected]> |
License: | GPL-3 |
Version: | 0.2.2 |
Built: | 2025-01-27 03:09:51 UTC |
Source: | https://github.com/gabriel-assuncao/covidibge |
This function adds deflator variables to PNAD COVID19 microdata. For deflation of income variables, the documentation provided through the following address must be used: https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_PNAD_COVID19/Microdados/Documentacao/COVIDIBGE_Deflator.pdf.
covid_deflator(data_covid, deflator.file)
covid_deflator(data_covid, deflator.file)
data_covid |
A tibble of PNAD COVID19 microdata read with |
deflator.file |
The deflator file for selected survey available on official website: (select the deflator zip file) - https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_PNAD_COVID19/Microdados/Documentacao/. |
A tibble with the data provided from PNAD COVID19 survey and the deflator variables added for use.
For more information, visit the survey official website <https://www.ibge.gov.br/estatisticas/investigacoes-experimentais/estatisticas-experimentais/27946-divulgacao-semanal-pnadcovid1?t=o-que-e> and consult the other functions of this package, described below.
get_covid for downloading, labeling, deflating and creating survey design object for PNAD COVID19 microdata.
read_covid for reading PNAD COVID19 microdata.
covid_labeller for labeling categorical variables from PNAD COVID19 microdata.
covid_design for creating PNAD COVID19 survey design object.
covid_example for getting the path of the PNAD COVID19 toy example files.
# Using data read from disk data_path <- covid_example(path="exampledata.csv") dictionary.path <- covid_example(path="dictionaryexample.xls") deflator.path <- covid_example(path="deflatorexample.xls") covid.df <- read_covid(microdata=data_path, vars=c("C001","C002")) covid.df <- covid_labeller(data_covid=covid.df, dictionary.file=dictionary.path) covid.df <- covid_deflator(data_covid=covid.df, deflator.file=deflator.path) # Downloading data covid.df2 <- get_covid(year=2020, month=5, vars=c("C001","C002"), labels=TRUE, deflator=FALSE, design=FALSE, reload=TRUE, curlopts=list(), savedir=tempdir()) deflator.path2 <- covid_example(path="deflatorexample.xls") covid.df2 <- covid_deflator(data_covid=covid.df2, deflator.file=deflator.path2)
# Using data read from disk data_path <- covid_example(path="exampledata.csv") dictionary.path <- covid_example(path="dictionaryexample.xls") deflator.path <- covid_example(path="deflatorexample.xls") covid.df <- read_covid(microdata=data_path, vars=c("C001","C002")) covid.df <- covid_labeller(data_covid=covid.df, dictionary.file=dictionary.path) covid.df <- covid_deflator(data_covid=covid.df, deflator.file=deflator.path) # Downloading data covid.df2 <- get_covid(year=2020, month=5, vars=c("C001","C002"), labels=TRUE, deflator=FALSE, design=FALSE, reload=TRUE, curlopts=list(), savedir=tempdir()) deflator.path2 <- covid_example(path="deflatorexample.xls") covid.df2 <- covid_deflator(data_covid=covid.df2, deflator.file=deflator.path2)
This function creates PNAD COVID19 survey object with its sample design for analysis using survey
package functions.
covid_design(data_covid)
covid_design(data_covid)
data_covid |
A tibble of PNAD COVID19 microdata read with |
An object of class survey.design
or svyrep.design
with the data from PNAD COVID19 and its sample design.
For more information, visit the survey official website <https://www.ibge.gov.br/estatisticas/investigacoes-experimentais/estatisticas-experimentais/27946-divulgacao-semanal-pnadcovid1?t=o-que-e> and consult the other functions of this package, described below.
get_covid for downloading, labeling, deflating and creating survey design object for PNAD COVID19 microdata.
read_covid for reading PNAD COVID19 microdata.
covid_labeller for labeling categorical variables from PNAD COVID19 microdata.
covid_deflator for adding deflator variables to PNAD COVID19 microdata.
covid_example for getting the path of the PNAD COVID19 toy example files.
# Using data read from disk data_path <- covid_example(path="exampledata.csv") dictionary.path <- covid_example(path="dictionaryexample.xls") deflator.path <- covid_example(path="deflatorexample.xls") covid.df <- read_covid(microdata=data_path, vars=c("C001","C002")) covid.df <- covid_labeller(data_covid=covid.df, dictionary.file=dictionary.path) covid.df <- covid_deflator(data_covid=covid.df, deflator.file=deflator.path) covid.svy <- covid_design(data_covid=covid.df) # Calculating proportion of people temporarily away from work if (!is.null(covid.svy)) survey::svymean(x=~C002, design=covid.svy, na.rm=TRUE) # Downloading data covid.df2 <- get_covid(year=2020, month=5, vars=c("C001","C002"), labels=TRUE, deflator=TRUE, design=FALSE, reload=TRUE, curlopts=list(), savedir=tempdir()) covid.svy2 <- covid_design(data_covid=covid.df2) # Calculating proportion of people temporarily away from work if (!is.null(covid.svy2)) survey::svymean(x=~C002, design=covid.svy2, na.rm=TRUE)
# Using data read from disk data_path <- covid_example(path="exampledata.csv") dictionary.path <- covid_example(path="dictionaryexample.xls") deflator.path <- covid_example(path="deflatorexample.xls") covid.df <- read_covid(microdata=data_path, vars=c("C001","C002")) covid.df <- covid_labeller(data_covid=covid.df, dictionary.file=dictionary.path) covid.df <- covid_deflator(data_covid=covid.df, deflator.file=deflator.path) covid.svy <- covid_design(data_covid=covid.df) # Calculating proportion of people temporarily away from work if (!is.null(covid.svy)) survey::svymean(x=~C002, design=covid.svy, na.rm=TRUE) # Downloading data covid.df2 <- get_covid(year=2020, month=5, vars=c("C001","C002"), labels=TRUE, deflator=TRUE, design=FALSE, reload=TRUE, curlopts=list(), savedir=tempdir()) covid.svy2 <- covid_design(data_covid=covid.df2) # Calculating proportion of people temporarily away from work if (!is.null(covid.svy2)) survey::svymean(x=~C002, design=covid.svy2, na.rm=TRUE)
This function provides the path of the microdata from month 5 of year 2020 of the PNAD COVID19 toy example files, loaded with this package.
covid_example(path = NULL)
covid_example(path = NULL)
path |
Name of file. If |
A vector with names of all the available PNAD COVID19 toy example files or the path for specific requested PNAD COVID19 toy example file.
For more information, visit the survey official website <https://www.ibge.gov.br/estatisticas/investigacoes-experimentais/estatisticas-experimentais/27946-divulgacao-semanal-pnadcovid1?t=o-que-e> and consult the other functions of this package, described below.
get_covid for downloading, labeling, deflating and creating survey design object for PNAD COVID19 microdata.
read_covid for reading PNAD COVID19 microdata.
covid_labeller for labeling categorical variables from PNAD COVID19 microdata.
covid_deflator for adding deflator variables to PNAD COVID19 microdata.
covid_design for creating PNAD COVID19 survey design object.
covid_example() covid_example(path="exampledata.csv") covid_example(path="dictionaryexample.xls") covid_example(path="deflatorexample.xls")
covid_example() covid_example(path="exampledata.csv") covid_example(path="dictionaryexample.xls") covid_example(path="deflatorexample.xls")
This function labels categorical variables from PNAD COVID19 microdata.
covid_labeller(data_covid, dictionary.file)
covid_labeller(data_covid, dictionary.file)
data_covid |
A tibble of PNAD COVID19 microdata read with |
dictionary.file |
The dictionary file for selected survey available on official website: (select a dictionary xls file) - https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_PNAD_COVID19/Microdados/Documentacao/. |
A tibble with the data provided from PNAD COVID19 survey and its categorical variables as factors with related labels.
For more information, visit the survey official website <https://www.ibge.gov.br/estatisticas/investigacoes-experimentais/estatisticas-experimentais/27946-divulgacao-semanal-pnadcovid1?t=o-que-e> and consult the other functions of this package, described below.
get_covid for downloading, labeling, deflating and creating survey design object for PNAD COVID19 microdata.
read_covid for reading PNAD COVID19 microdata.
covid_deflator for adding deflator variables to PNAD COVID19 microdata.
covid_design for creating PNAD COVID19 survey design object.
covid_example for getting the path of the PNAD COVID19 toy example files.
# Using data read from disk data_path <- covid_example(path="exampledata.csv") dictionary.path <- covid_example(path="dictionaryexample.xls") covid.df <- read_covid(microdata=data_path, vars=c("C001","C002")) covid.df <- covid_labeller(data_covid=covid.df, dictionary.file=dictionary.path) # Downloading data covid.df2 <- get_covid(year=2020, month=5, vars=c("C001","C002"), labels=FALSE, deflator=FALSE, design=FALSE, reload=TRUE, curlopts=list(), savedir=tempdir()) dictionary.path2 <- covid_example(path="dictionaryexample.xls") covid.df2 <- covid_labeller(data_covid=covid.df2, dictionary.file=dictionary.path2)
# Using data read from disk data_path <- covid_example(path="exampledata.csv") dictionary.path <- covid_example(path="dictionaryexample.xls") covid.df <- read_covid(microdata=data_path, vars=c("C001","C002")) covid.df <- covid_labeller(data_covid=covid.df, dictionary.file=dictionary.path) # Downloading data covid.df2 <- get_covid(year=2020, month=5, vars=c("C001","C002"), labels=FALSE, deflator=FALSE, design=FALSE, reload=TRUE, curlopts=list(), savedir=tempdir()) dictionary.path2 <- covid_example(path="dictionaryexample.xls") covid.df2 <- covid_labeller(data_covid=covid.df2, dictionary.file=dictionary.path2)
Core function of package. With this function only, the user can download a PNAD COVID19 microdata from a month and get a sample design object ready to use with survey
package functions.
get_covid( year, month, vars = NULL, labels = TRUE, deflator = TRUE, design = TRUE, reload = TRUE, curlopts = list(), savedir = tempdir() )
get_covid( year, month, vars = NULL, labels = TRUE, deflator = TRUE, design = TRUE, reload = TRUE, curlopts = list(), savedir = tempdir() )
year |
The year of the data to be downloaded. Must be a number equal to 2020. Vector not accepted. |
month |
The month of the year of the data to be downloaded. Must be number from 5 to 11. Vector not accepted. |
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. |
An object of class survey.design
or svyrep.design
with the data from PNAD COVID19 and its sample design, or a tibble with selected variables of the microdata, including the necessary survey design ones.
For more information, visit the survey official website <https://www.ibge.gov.br/estatisticas/investigacoes-experimentais/estatisticas-experimentais/27946-divulgacao-semanal-pnadcovid1?t=o-que-e> and consult the other functions of this package, described below.
read_covid for reading PNAD COVID19 microdata.
covid_labeller for labeling categorical variables from PNAD COVID19 microdata.
covid_deflator for adding deflator variables to PNAD COVID19 microdata.
covid_design for creating PNAD COVID19 survey design object.
covid_example for getting the path of the PNAD COVID19 toy example files.
covid.svy <- get_covid(year=2020, month=5, vars=c("C001","C002"), labels=TRUE, deflator=TRUE, design=TRUE, reload=TRUE, curlopts=list(), savedir=tempdir()) # Calculating proportion of people temporarily away from work if (!is.null(covid.svy)) survey::svymean(x=~C002, design=covid.svy, na.rm=TRUE)
covid.svy <- get_covid(year=2020, month=5, vars=c("C001","C002"), labels=TRUE, deflator=TRUE, design=TRUE, reload=TRUE, curlopts=list(), savedir=tempdir()) # Calculating proportion of people temporarily away from work if (!is.null(covid.svy)) survey::svymean(x=~C002, design=covid.svy, na.rm=TRUE)
This function reads PNAD COVID19 microdata.
read_covid(microdata, vars = NULL)
read_covid(microdata, vars = NULL)
microdata |
A comma-separated values file containing microdata from PNAD COVID19 survey, available on official website: (select a microdata file) - https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_PNAD_COVID19/Microdados/Dados/. |
vars |
Vector of variable names to be kept for analysis. Default is to keep all variables. |
A tibble with selected variables of the microdata, including the necessary survey design ones.
For more information, visit the survey official website <https://www.ibge.gov.br/estatisticas/investigacoes-experimentais/estatisticas-experimentais/27946-divulgacao-semanal-pnadcovid1?t=o-que-e> and consult the other functions of this package, described below.
get_covid for downloading, labeling, deflating and creating survey design object for PNAD COVID19 microdata.
covid_labeller for labeling categorical variables from PNAD COVID19 microdata.
covid_deflator for adding deflator variables to PNAD COVID19 microdata.
covid_design for creating PNAD COVID19 survey design object.
covid_example for getting the path of the PNAD COVID19 toy example files.
data_path <- covid_example(path="exampledata.csv") covid.df <- read_covid(microdata=data_path, vars=c("C001","C002"))
data_path <- covid_example(path="exampledata.csv") covid.df <- read_covid(microdata=data_path, vars=c("C001","C002"))