covid_design {COVIDIBGE} | R Documentation |
Create PNAD COVID19 survey object with its sample design
Description
This function creates PNAD COVID19 survey object with its sample design for analysis using survey
package functions.
Usage
covid_design(data_covid)
Arguments
data_covid |
A tibble of PNAD COVID19 microdata read with |
Value
An object of class survey.design
or svyrep.design
with the data from PNAD COVID19 and its sample design.
Note
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.
See Also
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.
Examples
# 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)