I can not install IBGEPesq on R to read the PNADs

4

I just downloaded PNGE 2013 from IBGE - and I tried to open it with the package for R that IBGE made, IBGEPesq. It is available as a .zip file at this address:

ftp://ftp.ibge.gov.br/Trabalho_e_Rendimento/Pesquisa_Nacional_por_Amostra_de_Domicilios_anual/microdados /2013/Learning_in_R.zip

I downloaded it from my working directory. And I executed:

    install.packages("IBGEPesq_1.0-4.zip",
                     repos=NULL)

    library(IBGEPesq)

But I get the following message:

    Error: package ‘IBGEPesq’ was built before R 3.0.0: please re-install it

Obviously, I've already tried to re-install. And I've already done it here:

    # Para atualizar os demais pacotes
    update.packages(checkBuilt = TRUE, ask = FALSE)

    # Por recomendação em um fórum (não entendi bem por quê) 
    install.packages('codetools')

And even then, the re-installation does not work. The same error returns. I'm using a Windows 7 and the data from the R session are:

    > sessionInfo()
    R version 3.1.1 (2014-07-10)
    Platform: x86_64-w64-mingw32/x64 (64-bit)

    locale:
    [1] LC_COLLATE=Portuguese_Brazil.1252  LC_CTYPE=Portuguese_Brazil.1252   
    [3] LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C                      
    [5] LC_TIME=Portuguese_Brazil.1252    

    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods   base     

    loaded via a namespace (and not attached):
    [1] tools_3.1.1

In advance, thank you for the help.

    
asked by anonymous 22.09.2014 / 12:26

2 answers

3

I recommend using the script created by Damico and Djalma, which can be found here . I've worked hard with it and it works perfectly.

You get the data via: download all microdata.R , and then perform the analysis with single-year-analysis examples.R .

There you will also find scripts for PME, POF and PISA.

    
22.09.2014 / 17:41
3

I know Damico's scripts, but I particularly prefer the solution I'm going to present here. Because the PNAD data is supplied as microdata, it is sufficient to have the dictionary of the search that the reading is trivial using any reader with a delimiter. For performance reasons I will use here the data.table and a C ++ function of the desc package that converts delimited text files into csv files, the fwf2csv (). Then just use the fread () function of data.table that reads csv's super fast.

Initially you will need the dictionary and microdata, both of which can be downloaded here:

With the microdata in the Data folder run the script:

#############PREPARAÇÃO DE DADOS##########
library(bit64)
library(data.table)
library(descr)
library(xlsx)

## Criando o dicionário a partir das três primeiras colunas da planilha
dicdom <- read.csv(file = 'dicdom.csv', header=F)
dicdom <- dicdom[complete.cases(dicdom),]
colnames(dicdom) <- c('inicio', 'tamanho', 'variavel')

## Parâmetro com o final de cada campo
end_dom = dicdom$inicio + dicdom$tamanho - 1

## Converte o microdado para um arquivo csv
fwf2csv(fwffile='Dados/DOM2013.txt', csvfile='dadosdom.csv', names=dicdom$variavel, begin=dicdom$inicio, end=end_dom)

## Efetua a leitura do conjunto de dados com o fread do data.table
dadosdom <- fread(input='dadosdom.csv', sep='auto', sep2='auto', integer64='double')
And that's it! There are 148,697 domiciles, just check with nrow (). Repeat the procedure for people's data.

    
23.09.2014 / 02:52