Skip to content

Commit

Permalink
version 0.6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel-Assuncao authored and cran-robot committed Apr 22, 2021
1 parent 37a6db9 commit 40a301d
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 70 deletions.
11 changes: 5 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: PNADcIBGE
Type: Package
Title: Downloading, Reading and Analysing PNADC Microdata
Version: 0.6.2
Version: 0.6.3
Authors@R: c(person("Douglas", "Braga", email = "pacotesipd@ibge.gov.br",
role = c("aut")),
person("Gabriel", "Assuncao", email = "pacotesipd@ibge.gov.br",
Expand All @@ -13,18 +13,17 @@ Description: Provides tools for downloading, reading and analysing the PNADC,
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: survey, readr, dplyr, magrittr, RCurl, utils, timeDate,
readxl, tibble
Imports: survey, readr, dplyr, magrittr, projmgr, httr, RCurl, utils,
timeDate, readxl, tibble
Suggests: tidyverse, convey
License: GPL-3
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.0.1
NeedsCompilation: no
Author: Douglas Braga [aut],
Gabriel Assuncao [aut, cre],
Luna Hidalgo [ctb]
Maintainer: Gabriel Assuncao <pacotesipd@ibge.gov.br>
Packaged: 2021-01-26 00:12:25 UTC; gabriel.assuncao
Packaged: 2021-04-21 16:08:02 UTC; gabriel.assuncao
Repository: CRAN
Date/Publication: 2021-01-26 06:30:02 UTC
Date/Publication: 2021-04-22 04:50:31 UTC
22 changes: 11 additions & 11 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
1831aa308f238b072431fac85777d079 *DESCRIPTION
dd86fd45b4392c5af8ec7da92dddb3ec *NAMESPACE
d49edd581442a4cf8c5e07a3c75d611a *R/example.R
2bfd14484eda14e4ffb0ae9422cd04cb *R/get_pnadc.R
0548e995b024dd9c977ea8939e9d4409 *R/pnadc_deflator.R
9432cf2f7fe5bc569f39453349f12631 *R/pnadc_design.R
a33e8441ceb0a38fea254c1bfa240ea9 *R/pnadc_labeller.R
2511726ff6c1ddb471b47d08c4196a7f *R/read_pnadc.R
58ace4183ad2c728f4421c67b8dde105 *DESCRIPTION
4e8ccb39b51f2e4981a2e79fa43b4de0 *NAMESPACE
cbc206f5800c1f1b9f4eb4122e6b37be *R/example.R
e5da87a1945a88c3f78c09c30423d5c6 *R/get_pnadc.R
6af876c636515ee88657488d049ddb00 *R/pnadc_deflator.R
f0dcea50a104eb3d8f6cb030dec7d983 *R/pnadc_design.R
e783cb1d3be81169ff56dbc7cd6b4c2d *R/pnadc_labeller.R
51d7ff2791149f61f71d37ca1b22017c *R/read_pnadc.R
de5f8eba02cdc1eab045e7b2f180d3a4 *README.md
9ccca52574f68fe6860f2b395702f33a *inst/extdata/deflatorexample.xls
d10e8245d66fa52552a44fd4f013c266 *inst/extdata/dictionaryexample.xls
52efec701f05546c2964b8c9c77d8cfc *inst/extdata/exampledata.txt
9968b588734160713e5fe4534f60442f *inst/extdata/input_example.txt
a2ed000a1d89be44674ce68f3511dc6d *man/get_pnadc.Rd
53f84d12a9975fcd4380337119e3ff79 *man/get_pnadc.Rd
bd2080c92c6e455ecebe17eb15715412 *man/pnadc_deflator.Rd
f73ae6dc01575d3af6d1dc288c6454fe *man/pnadc_design.Rd
58dd499e84e42f63668b40ad83dea935 *man/pnadc_example.Rd
4777cb6e58ffa5b529c7d7e046d0a2f9 *man/pnadc_design.Rd
2aad64188e2cdb83441c36a1dd9cb27b *man/pnadc_example.Rd
aa72f25e999a9acd67f2d93c51cffe03 *man/pnadc_labeller.Rd
56f67c940159f2407678fb8e14269641 *man/read_pnadc.Rd
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ export(pnadc_labeller)
export(read_pnadc)
import(RCurl)
import(dplyr)
import(httr)
import(magrittr)
import(projmgr)
import(readr)
import(readxl)
import(survey)
Expand Down
4 changes: 2 additions & 2 deletions R/example.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Get the path of the quarter PNADC example files
#' @description This function provides the path of the quarter PNADC example files, loaded with this package.
#' @import survey readr dplyr magrittr RCurl utils timeDate readxl tibble
#' @description This function provides the path of the microdata from quarter 4 of year 2017 of the PNADC example files, loaded with this package.
#' @import survey readr dplyr magrittr projmgr httr RCurl utils timeDate readxl tibble
#' @param path Name of file. If \code{NULL}, the quarter PNADC example files names will be listed.
#' @return A vector with names of all the available quarter PNADC example files or the path for specific requested quarter PNADC example file.
#' @note For more information, visit the survey official website <\url{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.
Expand Down
100 changes: 67 additions & 33 deletions R/get_pnadc.R

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions R/pnadc_deflator.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' 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:\cr Quarter - \url{https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_continua/Trimestral/Microdados/Documentacao/PNADcIBGE_Deflator_Trimestral.pdf}.\cr Annual per Interview - \url{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}.\cr Annual per Topic - \url{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}.
#' @import survey readr dplyr magrittr RCurl utils timeDate readxl tibble
#' @import survey readr dplyr magrittr projmgr httr RCurl utils timeDate readxl tibble
#' @param data_pnadc A tibble of PNADC microdata read with \code{read_pnadc} function.
#' @param deflator.file The deflator file for selected survey available on official website:\cr Quarter (select the deflator zip file) - \url{https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_continua/Trimestral/Microdados/Documentacao/}.\cr Annual per Interview (select a deflator xls file, according to the appropriated year) - \url{https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_continua/Anual/Microdados/Visita/Documentacao_Geral/}.\cr Annual per Topic (select a deflator xls file, according to the appropriated period and, then, inside the documentation folder, choose the desired year) - \url{https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_continua/Anual/Microdados/Trimestre/}.
#' @return A tibble with the data provided from PNADC survey and the deflator variables added for use.
Expand Down Expand Up @@ -45,11 +45,11 @@ pnadc_deflator <- function(data_pnadc, deflator.file) {
data_pnadc <- tibble::as_tibble(data_pnadc)
}
else {
warning("Merge variables required for adding deflator variables are missing.")
message("Merge variables required for adding deflator variables are missing.")
}
}
else {
warning("Sample design was already defined for microdata, so adding deflator variables is not possible.")
message("The microdata object is not of the tibble class or sample design was already defined for microdata, so adding deflator variables is not possible.")
}
return(data_pnadc)
}
10 changes: 5 additions & 5 deletions R/pnadc_design.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Create PNADC survey object with its sample design
#' @description This function creates PNADC survey object with its sample design for analysis using \code{survey} package functions.
#' @import survey readr dplyr magrittr RCurl utils timeDate readxl tibble
#' @import survey readr dplyr magrittr projmgr httr RCurl utils timeDate readxl tibble
#' @param data_pnadc A tibble of PNADC microdata read with \code{read_pnadc} function.
#' @return An object of class \code{survey.design} with the data from PNADC and its sample design.
#' @note For more information, visit the survey official website <\url{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.
Expand All @@ -17,14 +17,14 @@
#' \donttest{
#' pnadc.svy <- pnadc_design(data_pnadc=pnadc.df)
#' # Calculating unemployment rate
#' survey::svymean(x=~VD4002, design=pnadc.svy, na.rm=TRUE)}
#' if (!is.null(pnadc.svy)) survey::svymean(x=~VD4002, design=pnadc.svy, na.rm=TRUE)}
#' \donttest{
#' # Downloading data
#' pnadc.df2 <- get_pnadc(year=2017, quarter=4, vars="VD4002", defyear=2017, defperiod=4,
#' labels=TRUE, deflator=TRUE, design=FALSE, savedir=tempdir())
#' pnadc.svy2 <- pnadc_design(data_pnadc=pnadc.df2)
#' # Calculating unemployment rate
#' survey::svymean(x=~VD4002, design=pnadc.svy2, na.rm=TRUE)}
#' if (!is.null(pnadc.svy2)) survey::svymean(x=~VD4002, design=pnadc.svy2, na.rm=TRUE)}
#' @export

pnadc_design <- function(data_pnadc) {
Expand All @@ -46,12 +46,12 @@ pnadc_design <- function(data_pnadc) {
}
}
else {
warning("Weight variables required for sample design are missing.")
message("Weight variables required for sample design are missing.")
data_posterior <- data_pnadc
}
}
else {
warning("Sample design was already defined for microdata, so applying another design is not possible.")
message("The microdata object is not of the tibble class or sample design was already defined for microdata, so applying another design is not possible.")
data_posterior <- data_pnadc
}
return(data_posterior)
Expand Down
4 changes: 2 additions & 2 deletions R/pnadc_labeller.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Label categorical variables from PNADC microdata
#' @description This function labels categorical variables from PNADC microdata.
#' @import survey readr dplyr magrittr RCurl utils timeDate readxl tibble
#' @import survey readr dplyr magrittr projmgr httr RCurl utils timeDate readxl tibble
#' @param data_pnadc A tibble of PNADC microdata read with \code{read_pnadc} function.
#' @param dictionary.file The dictionary file for selected survey available on official website:\cr Quarter (select the dictionary and input zip file) - \url{https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_continua/Trimestral/Microdados/Documentacao/}.\cr Annual per Interview (select a dictionary xls file, according to the appropriated interview and, then, inside the documentation folder, choose the desired year) - \url{https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_continua/Anual/Microdados/Visita/}.\cr Annual per Topic (select a dictionary xls file, according to the appropriated quarter related to the topic, inside the documentation folder) - \url{https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_continua/Anual/Microdados/Trimestre/}.
#' @return A tibble with the data provided from PNADC survey and its categorical variables as factors with related labels.
Expand Down Expand Up @@ -61,7 +61,7 @@ pnadc_labeller <- function(data_pnadc, dictionary.file) {
}
}
else {
warning("Sample design was already defined for microdata, so labelling categorical variables is not possible.")
message("The microdata object is not of the tibble class or sample design was already defined for microdata, so labelling categorical variables is not possible.")
}
return(data_pnadc)
}
4 changes: 2 additions & 2 deletions R/read_pnadc.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Read PNADC microdata
#' @description This function reads PNADC microdata.
#' @import survey readr dplyr magrittr RCurl utils timeDate readxl tibble
#' @import survey readr dplyr magrittr projmgr httr RCurl utils timeDate readxl tibble
#' @param microdata A text file containing microdata from PNADC survey, available on official website:\cr Quarter (select a microdata file, according to the appropriated year and, then, quarter) - \url{https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_continua/Trimestral/Microdados/}.\cr Annual per Interview (select a microdata file, according to the appropriated interview and, then, inside the data folder, choose the desired year) - \url{https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_continua/Anual/Microdados/Visita/}.\cr Annual per Topic (select a microdata file, according to the appropriated quarter related to the topic and, then, inside the data folder, choose the desired year) - \url{https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_continua/Anual/Microdados/Trimestre/}.
#' @param input_txt A text file, related to the microdata, containing the input script for SAS, available on official website:\cr Quarter (select the dictionary and input zip file) - \url{https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_continua/Trimestral/Microdados/Documentacao/}.\cr Annual per Interview (select a input txt file, according to the appropriated interview and, then, inside the documentation folder, choose the desired year) - \url{https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_continua/Anual/Microdados/Visita/}.\cr Annual per Topic (select a input txt file, according to the appropriated quarter related to the topic, inside the documentation folder) - \url{https://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_continua/Anual/Microdados/Trimestre/}.
#' @param vars Vector of variable names to be kept for analysis. Default is to keep all variables.
Expand All @@ -20,7 +20,7 @@ read_pnadc <- function(microdata, input_txt, vars = NULL) {
if (!is.null(vars)) {
if (any(!(vars %in% input$X2))) {
missvar <- vars[!(vars %in% input$X2)]
warning(paste("Variables", paste(missvar, collapse=", "), "not present in microdata.\n"))
message(paste("Variables", paste(missvar, collapse=", "), "not present in microdata.\n"))
}
input %<>% subset(X2 %in% c("Ano", "Trimestre", "UF", "UPA", "Estrato", "V1008", "V1027", "V1029", "V1030", "V1031", "posest", "V2003", vars))
}
Expand Down
6 changes: 3 additions & 3 deletions man/get_pnadc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/pnadc_design.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/pnadc_example.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 40a301d

Please sign in to comment.