knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)

brLabor

The goal of package "brLabor" is to extract data from the Brazilian Ministry of Labor and Social Security. At for this moment you can have access to the Annual National Social Recording (Relação Anual de Trabalhadores - rais) (deprecated, see below), to the Colective agreements between workers and companies' unions, as well as labor accidents.

Installation

You can install trabalho from github with:

# install.packages("devtools")
devtools::install_github("jjesusfilho/brLabor")

Rais data

Getting data from RAIS is deprecated. The best way to get this data is through Base dos Dados.

You can download the rais data from several states and also include more than one CNAE or CBO. As for the year, the function only allows one year at a time. It will download the file in 7-zip format, then decompress it to a txt file, and finally read the data into R in chunks of 1000 lines each time. After that, it will remove the files from the directory. You need at least 9Gb of free space in your HD if you want to extract the rais of São Paulo.

As for the CNAE and CBO, smaller numbers will download more classes. First example, if you want to extract ocupations from high ranks of the tree branches, like judges, mayors and senators, you put CBO="111". The same with the CNAE.

Example.

df<-rais(uf=c("SP","RJ"),CNAE="84","111")

The description of each variable can be accessed through the following data:

data(dic)

So the CBO number corresponds to variable X8. To find the occupation's descriptions, you have to access the CBO data:

data(cbo)

After that, you can replace the numbers with their respective descriptions. There is a function from the miscBR package that does the work for you. The first argument is the column to be replaced, the second one is the column from the second data.frame to find matches and the third argument is the replacement that comes from the second data.frame:

devtools::install_github("jjesusfilho/miscBR")
df$X8<-miscBR::subs(df$X8,cbo$cbo,cbo$desc)


jjesusfilho/trabalho documentation built on Oct. 31, 2021, 10:20 p.m.