Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dicionariosIBGE/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: dicionariosIBGE
Type: Package
Title: Dictionaries for reading microdata surveys from IBGE
Version: 1.6
Date: 2014-08-13
Version: 1.7
Date: 2022-06-22
Author: Alexandre Rademaker <alexandre.rademaker@fgv.br>
Maintainer: Alexandre Rademaker <alexandre.rademaker@fgv.br>
Description: This package contains the dictionaries for reading microdata
Expand Down
2 changes: 2 additions & 0 deletions dicionariosIBGE/NAMESPACE
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
exportPattern("^[^\\.]")
importFrom("utils", "setTxtProgressBar", "txtProgressBar",
"type.convert")
38 changes: 19 additions & 19 deletions dicionariosIBGE/R/le.pesquisa.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,67 +3,67 @@ le.pesquisa <- function(dicionario, pathname.in, codigos, rotulos = NULL, tbloco
inicios <- numeric(0)
tamanhos <- numeric(0)

#Condições da função:
## Se é um NA, print "You must provide the number of lines of the data file"
if(is.na(nlines))
stop(paste("You must provide the number of lines of the data file", substitute(dicionario), sep=" "))

if( !all(c("inicio","cod", "tamanho", "desc") == colnames(dicionario)) )

## Se os valores forem falsos, print "The", substitute(dicionario)," is not a valid object for 'dicionario' parameter"
if(!all(c("inicio","cod", "tamanho", "desc") == colnames(dicionario)) )
stop(paste("The", substitute(dicionario)," is not a valid object for 'dicionario' parameter",sep=" "))

if( ! all(c("cod", "valor", "rotulo") == colnames(rotulos)) )

## Se os valores forem falsos, print "The", substitute(dicionario)," is not a valid object for 'rotulos' parameter"
if(!all(c("cod", "valor", "rotulo") == colnames(rotulos)) )
stop(paste("The", substitute(rotulos), "is not a valid object for 'rotulos' parameter", sep=" "))

tmp <- merge(data.frame(cod = codigos, stringsAsFactors = FALSE), dicionario)
inicios <- tmp[,"inicio"]
tamanhos <- tmp[,"tamanho"]
inicios <- tmp[ ,"inicio"]
tamanhos <- tmp[ ,"tamanho"]
rm(tmp)

if ( length(inicios) == 0)
stop(paste("Variables do not exist in", substitute(dicionario), sep=" "))
## Se o início do dado for == 0, print "Variables do not exist in", substitute(dicionario)
if (length(inicios) == 0)
stop(paste("Variables do not exist in", substitute(dicionario), sep=" "))

## Aqui é quando está lendo? "Will display a progress bar on the R console via text representation
pb <- txtProgressBar(min = 0, max = (nlines/tbloco) * length(codigos), style = 3)

arq <- file(pathname.in, open="r")
arq <- file(pathname.in, open = "r")
dados <- NULL

process <- 0
cont <- TRUE
while (cont) {
bloco <- scan(file = arq, what = "", sep = "", nlines = tbloco, quiet = TRUE)
bloco <- scan(file = arq, what = " ", sep = " ", nlines = tbloco, quiet = TRUE)
df.temp <- NULL
for (k in 1:length(inicios)) {
coluna <- substr(bloco, inicios[k], inicios[k] + tamanhos[k] - 1)
coluna <- substr(bloco, inicios[k], inicios[k] + tamanhos[k] - 1)
if(is.null(df.temp))
df.temp <- data.frame(type.convert(coluna))
else
df.temp <- cbind(df.temp, data.frame(type.convert(coluna)))
process <- process + 1
setTxtProgressBar(pb, process)
}
## Se os dados forem nulos
if(is.null(dados))
dados <- df.temp
else
dados <- rbind(dados, df.temp)

if (length(bloco) < tbloco)
cont <- FALSE
}

close(arq)
rm(bloco, df.temp)
colnames(dados) <- codigos
close(pb)

if(is.null(rotulos)){
return(dados)
}

for(n in 1:ncol(dados)){
colname <- colnames(dados)[n]
if(colname %in% rotulos$cod){
tmp <- rotulos[rotulos$cod == colname, 2:3]
dados[,n] <- factor(dados[,n], levels = tmp[,1], labels = tmp[,2])
}
}

return(dados)
}
}
Binary file modified dicionariosIBGE/data/dicPNAD2003.rda
Binary file not shown.
Binary file modified dicionariosIBGE/data/dicPNAD2004.rda
Binary file not shown.
Binary file modified dicionariosIBGE/data/dicPNAD2005.rda
Binary file not shown.
Binary file modified dicionariosIBGE/data/dicPNAD2007.rda
Binary file not shown.
Binary file modified dicionariosIBGE/data/dicPNAD2009.rda
Binary file not shown.
Binary file added dicionariosIBGE/data/dicPNAD2011.rda
Binary file not shown.
Binary file modified dicionariosIBGE/data/dicPNAD2012.rda
Binary file not shown.
Binary file added dicionariosIBGE/data/dicPNAD2013.rda
Binary file not shown.
Binary file added dicionariosIBGE/data/dicPNAD2014.rda
Binary file not shown.
Binary file added dicionariosIBGE/data/dicPNAD2015.rda
Binary file not shown.
Binary file added dicionariosIBGE/data/dicPOF2017.2018.rda
Binary file not shown.
31 changes: 31 additions & 0 deletions dicionariosIBGE/man/dic10pof2017.2018.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
\name{dic_10_pof_2017_2018}
\alias{dic_10_pof_2017_2018}
\docType{data}

\encoding{UTF-8}
\title{Dictionary for diet features record from POF 2017-2018 survey}

\description{

Data dictionary for reading "CARACTERISTICAS_DIETA.txt" file
(diet features record from POF 2017-2018 survey).


}

\format{
This dictionary is a data frame with one line for each variable,
and it has 4 columms, with important information of each variable.

\tabular{lll}{
inicio \tab numeric \tab Position of the value's first character in
the data file \cr
cod \tab character \tab Variable code \cr
tamanho \tab numeric \tab Field size \cr
desc \tab character \tab Short description\cr

}
}
\source{The dictionaries were made based on the documentation of the
POF survey available at \url{http://www.ibge.gov.br}.}
\keyword{datasets}
31 changes: 31 additions & 0 deletions dicionariosIBGE/man/dic11pof2017.2018.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
\name{dic_11_pof_2017_2018}
\alias{dic_11_pof_2017_2018}
\docType{data}

\encoding{UTF-8}
\title{Dictionary for food consumption record from POF 2017-2018 survey}

\description{

Data dictionary for reading "CONSUMO_ALIMENTAR.txt" file
(food consumption record from POF 2017-2018 survey).


}

\format{
This dictionary is a data frame with one line for each variable,
and it has 4 columms, with important information of each variable.

\tabular{lll}{
inicio \tab numeric \tab Position of the value's first character in
the data file \cr
cod \tab character \tab Variable code \cr
tamanho \tab numeric \tab Field size \cr
desc \tab character \tab Short description\cr

}
}
\source{The dictionaries were made based on the documentation of the
POF survey available at \url{http://www.ibge.gov.br}.}
\keyword{datasets}
31 changes: 31 additions & 0 deletions dicionariosIBGE/man/dic12pof2017.2018.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
\name{dic_12_pof_2017_2018}
\alias{dic_12_pof_2017_2018}
\docType{data}

\encoding{UTF-8}
\title{Dictionary for life conditions record from POF 2017-2018 survey}

\description{

Data dictionary for reading "CONDICOES_VIDA.txt" file
(life conditions record from POF 2017-2018 survey).


}

\format{
This dictionary is a data frame with one line for each variable,
and it has 4 columms, with important information of each variable.

\tabular{lll}{
inicio \tab numeric \tab Position of the value's first character in
the data file \cr
cod \tab character \tab Variable code \cr
tamanho \tab numeric \tab Field size \cr
desc \tab character \tab Short description\cr

}
}
\source{The dictionaries were made based on the documentation of the
POF survey available at \url{http://www.ibge.gov.br}.}
\keyword{datasets}
31 changes: 31 additions & 0 deletions dicionariosIBGE/man/dic13pof2017.2018.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
\name{dic_13_pof_2017_2018}
\alias{dic_13_pof_2017_2018}
\docType{data}

\encoding{UTF-8}
\title{Dictionary for restriction / products and health services record from POF 2017-2018 survey}

\description{

Data dictionary for reading "RESTRICAO_PRODUTOS_SERVICOS_SAUDE.txt" file
(restriction / products and health services record from POF 2017-2018 survey).


}

\format{
This dictionary is a data frame with one line for each variable,
and it has 4 columms, with important information of each variable.

\tabular{lll}{
inicio \tab numeric \tab Position of the value's first character in
the data file \cr
cod \tab character \tab Variable code \cr
tamanho \tab numeric \tab Field size \cr
desc \tab character \tab Short description\cr

}
}
\source{The dictionaries were made based on the documentation of the
POF survey available at \url{http://www.ibge.gov.br}.}
\keyword{datasets}
31 changes: 31 additions & 0 deletions dicionariosIBGE/man/dic14pof2017.2018.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
\name{dic_14_pof_2017_2018}
\alias{dic_14_pof_2017_2018}
\docType{data}

\encoding{UTF-8}
\title{Dictionary for non-monetary services POF 2 record from POF 2017-2018 survey}

\description{

Data dictionary for reading "SERVICO_NAO_MONETARIO_POF2.txt" file
(non-monetary services POF 2 record from POF 2017-2018 survey).


}

\format{
This dictionary is a data frame with one line for each variable,
and it has 4 columms, with important information of each variable.

\tabular{lll}{
inicio \tab numeric \tab Position of the value's first character in
the data file \cr
cod \tab character \tab Variable code \cr
tamanho \tab numeric \tab Field size \cr
desc \tab character \tab Short description\cr

}
}
\source{The dictionaries were made based on the documentation of the
POF survey available at \url{http://www.ibge.gov.br}.}
\keyword{datasets}
31 changes: 31 additions & 0 deletions dicionariosIBGE/man/dic15pof2017.2018.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
\name{dic_15_pof_2017_2018}
\alias{dic_15_pof_2017_2018}
\docType{data}

\encoding{UTF-8}
\title{Dictionary for non-monetary services POF 4 record from POF 2017-2018 survey}

\description{

Data dictionary for reading "SERVICO_NAO_MONETARIO_POF4.txt" file
(non-monetary services POF 4 record from POF 2017-2018 survey).


}

\format{
This dictionary is a data frame with one line for each variable,
and it has 4 columms, with important information of each variable.

\tabular{lll}{
inicio \tab numeric \tab Position of the value's first character in
the data file \cr
cod \tab character \tab Variable code \cr
tamanho \tab numeric \tab Field size \cr
desc \tab character \tab Short description\cr

}
}
\source{The dictionaries were made based on the documentation of the
POF survey available at \url{http://www.ibge.gov.br}.}
\keyword{datasets}
2 changes: 1 addition & 1 deletion dicionariosIBGE/man/dic1pof2008.2009.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@
}
}
\source{The dictionaries were made based on the documentation of the
PNAD survey available at \url{http://www.ibge.gov.br}.}
POF survey available at \url{http://www.ibge.gov.br}.}
\keyword{datasets}
31 changes: 31 additions & 0 deletions dicionariosIBGE/man/dic1pof2017.2018.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
\name{dic_1_pof_2017_2018}
\alias{dic_1_pof_2017_2018}
\docType{data}

\encoding{UTF-8}
\title{Dictionary for domiciles record POF 2017-2018 survey}

\description{

Data dictionary for reading "MORADOR.txt" file
(residents (type 1) record from POF 2017-2018 survey).


}

\format{
This dictionary is a data frame with one line for each variable,
and it has 4 columms, with important information of each variable.

\tabular{lll}{
inicio \tab numeric \tab Position of the value's first character in
the data file \cr
cod \tab character \tab Variable code \cr
tamanho \tab numeric \tab Field size \cr
desc \tab character \tab Short description\cr

}
}
\source{The dictionaries were made based on the documentation of the
POF survey available at \url{http://www.ibge.gov.br}.}
\keyword{datasets}
31 changes: 31 additions & 0 deletions dicionariosIBGE/man/dic1pof20172018.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
\name{dic_1_pof_2017_2018}
\alias{dic_1_pof_2017_2018}
\docType{data}

\encoding{UTF-8}
\title{Dictionary for domiciles record POF 2017-2018 survey}

\description{

Data dictionary for reading "MORADOR.txt" file
(residents (type 1) record from POF 2017-2018 survey).


}

\format{
This dictionary is a data frame with one line for each variable,
and it has 4 columms, with important information of each variable.

\tabular{lll}{
inicio \tab numeric \tab Position of the value's first character in
the data file \cr
cod \tab character \tab Variable code \cr
tamanho \tab numeric \tab Field size \cr
desc \tab character \tab Short description\cr

}
}
\source{The dictionaries were made based on the documentation of the
POF survey available at \url{http://www.ibge.gov.br}.}
\keyword{datasets}
Loading