knitr::opts_chunk$set(
warning = FALSE, # show warnings during codebook generation
message = FALSE, # show messages during codebook generation
error = TRUE, # do not interrupt codebook generation in case of errors,
# usually better for debugging
echo = TRUE # show R code
)
ggplot2::theme_set(ggplot2::theme_bw())
# set base directory
basedir = "/home/ecco_rais/data/clean/RAIS-homogenized/output/"
# adjust as necessary
startyear = 2003
endyear = 2004
# libraries
library(codebook)
library(rio)
# Start the codebook loop
#for ( year in startyear:endyear) {
year = "2008"
# for CSV
codebook_data <- fread(file.path(basedir, paste0("harmo_", year, ".csv")))
# omit the following lines, if your missing values are already properly labelled
codebook_data <- detect_missing(codebook_data,
only_labelled = TRUE, # only labelled values are autodetected as
# missing
negative_values_are_missing = FALSE, # negative values are missing values
ninety_nine_problems = TRUE, # 99/999 are missing values, if they
# are more than 5 MAD from the median
)
# If you are not using formr, the codebook package needs to guess which items
# form a scale. The following line finds item aggregates with names like this:
# scale = scale_1 + scale_2R + scale_3R
# identifying these aggregates allows the codebook function to
# automatically compute reliabilities.
# However, it will not reverse items automatically.
codebook_data <- detect_scales(codebook_data)
## Warning in detect_scales(codebook_data): cnae items found, but no aggregate
## Warning in detect_scales(codebook_data): active items found, but no aggregate
## Warning in detect_scales(codebook_data): cbo items found, but no aggregate
codebook_data <- as.data.table(codebook_data)
codebook(codebook_data)
## Warning: Couldn't find skimmers for class: integer64; No user-defined `sfl` provided. Falling
## back to `character`.
## Warning: Couldn't find skimmers for class: integer64; No user-defined `sfl` provided. Falling
## back to `character`.
## Warning: Couldn't find skimmers for class: integer64; No user-defined `sfl` provided. Falling
## back to `character`.
## Warning in max(f): no non-missing arguments to max; returning -Inf
## Warning: Couldn't find skimmers for class: integer64; No user-defined `sfl` provided. Falling
## back to `character`.
## Warning: Couldn't find skimmers for class: integer64; No user-defined `sfl` provided. Falling
## back to `character`.
## Warning: Couldn't find skimmers for class: integer64; No user-defined `sfl` provided. Falling
## back to `character`.
## Warning: Couldn't find skimmers for class: integer64; No user-defined `sfl` provided. Falling
## back to `character`.
## Warning: Couldn't find skimmers for class: integer64; No user-defined `sfl` provided. Falling
## back to `character`.
## Warning: Couldn't find skimmers for class: integer64; No user-defined `sfl` provided. Falling
## back to `character`.
## Warning: Couldn't find skimmers for class: integer64; No user-defined `sfl` provided. Falling
## back to `character`.
## Warning: Couldn't find skimmers for class: integer64; No user-defined `sfl` provided. Falling
## back to `character`.
## Warning: Couldn't find skimmers for class: integer64; No user-defined `sfl` provided. Falling
## back to `character`.
Dataset name: codebook_data
The dataset has N=59706419 rows and 48 columns. 24506543 rows have no missing values on any column.
|
#Variables
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
adm_date | numeric | 0 | 1 | 1e+06 | 4e+06 | 3.1e+07 | 8277494 | 8427308 | ▇▂▂▂▁ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
separation_cause | numeric | 0 | 1 | 0 | 0 | 80 | 5.151158 | 8.524752 | ▇▁▁▁▁ | NA |
## Error in `ggplot2::geom_histogram()`:
## ! Problem while computing position.
## ℹ Error occurred in the 1st layer.
## Caused by error in `if (...) NULL`:
## ! missing value where TRUE/FALSE needed
0 missing values.
name | data_type | n_missing | complete_rate | n_unique | empty | min | max | whitespace | label |
---|---|---|---|---|---|---|---|---|---|
cei | character | 0 | 1 | 40947 | 0 | 1 | 21 | 0 | NA |
105 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
cnae20 | numeric | 105 | 0.9999982 | -1 | 47890 | 99008 | 54139.74 | 27088.76 | ▃▂▇▂▇ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
cnae95 | numeric | 0 | 1 | -1 | 52493 | 99007 | 54292.99 | 23829.52 | ▃▂▇▇▂ | NA |
## Error in `ggplot2::geom_histogram()`:
## ! Problem while computing position.
## ℹ Error occurred in the 1st layer.
## Caused by error in `if (...) NULL`:
## ! missing value where TRUE/FALSE needed
0 missing values.
name | data_type | n_missing | complete_rate | n_unique | empty | min | max | whitespace | label |
---|---|---|---|---|---|---|---|---|---|
cpf | character | 0 | 1 | 48182481 | 0 | 1 | 21 | 0 | NA |
0 missing values.
name | data_type | n_missing | complete_rate | n_unique | empty | min | max | whitespace | label |
---|---|---|---|---|---|---|---|---|---|
termination_day | character | 0 | 1 | 32 | 0 | 1 | 12 | 0 | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
dob | numeric | 0 | 1 | 1e+06 | 1.5e+07 | 5.1e+07 | 15633993 | 8783292 | ▇▇▇▁▁ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
active1231 | numeric | 0 | 1 | 0 | 1 | 1 | 0.6605917 | 0.4735085 | ▅▁▁▁▇ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
sex | numeric | 0 | 1 | 0 | 0 | 1 | 0.3908393 | 0.4879385 | ▇▁▁▁▅ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
schooling | numeric | 0 | 1 | 1 | 7 | 11 | 6.141199 | 1.916728 | ▂▅▇▃▁ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
hired_hours | numeric | 0 | 1 | 1 | 44 | 44 | 41.33881 | 6.269506 | ▁▁▁▁▇ | NA |
## Error in `ggplot2::geom_histogram()`:
## ! Problem while computing stat.
## ℹ Error occurred in the 1st layer.
## Caused by error in `seq_len()`:
## ! argument must be coercible to non-negative integer
0 missing values.
name | data_type | n_missing | complete_rate | n_unique | empty | min | max | whitespace | label |
---|---|---|---|---|---|---|---|---|---|
firmID | character | 0 | 1 | 3048597 | 0 | 15 | 21 | 0 | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
alvara_ind | numeric | 0 | 1 | 1 | 2 | 2 | 1.999555 | 0.0210834 | ▁▁▁▁▇ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
cei_avail | numeric | 0 | 1 | 0 | 0 | 1 | 0.0189184 | 0.136237 | ▇▁▁▁▁ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
pat | numeric | 0 | 1 | 0 | 0 | 1 | 0.2919284 | 0.4546496 | ▇▁▁▁▃ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
simples | numeric | 0 | 1 | 0 | 0 | 1 | 0.2105439 | 0.407695 | ▇▁▁▁▂ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
termination_month | numeric | 0 | 1 | 0 | 0 | 12 | 2.336911 | 3.856444 | ▇▁▁▁▁ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
muni | numeric | 0 | 1 | 110001 | 351880 | 530010 | 346047.7 | 84449.54 | ▁▂▇▂▁ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
nationality | numeric | 0 | 1 | 10 | 10 | 50 | 10.03104 | 0.95423 | ▇▁▁▁▁ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
legal_form | numeric | 0 | 1 | 1015 | 2062 | 5002 | 2046.416 | 673.7039 | ▂▇▁▁▁ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | n_unique | empty | min | max | whitespace | label |
---|---|---|---|---|---|---|---|---|---|
name | character | 0 | 1 | 35100774 | 0 | 3 | 52 | 0 | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
ctps | numeric | 0 | 1 | 0 | 55586 | 1e+08 | 784855.8 | 3777196 | ▇▁▁▁▁ | NA |
622145 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
cbo02 | numeric | 622145 | 0.9895799 | 111215 | 514320 | 992225 | 525473.1 | 199195.2 | ▃▇▇▆▂ | NA |
6423599 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
cbo94 | numeric | 6423599 | 0.8924136 | 12110 | 53270 | 99190 | 56700.07 | 26503.64 | ▃▇▅▂▆ | NA |
## Error in `ggplot2::geom_histogram()`:
## ! Problem while computing position.
## ℹ Error occurred in the 1st layer.
## Caused by error in `if (...) NULL`:
## ! missing value where TRUE/FALSE needed
0 missing values.
name | data_type | n_missing | complete_rate | n_unique | empty | min | max | whitespace | label |
---|---|---|---|---|---|---|---|---|---|
pis | character | 0 | 1 | 48573811 | 0 | 1 | 21 | 0 | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
disabled | numeric | 0 | 1 | 0 | 1 | 1 | 0.9927155 | 0.0850376 | ▁▁▁▁▇ | NA |
9016192 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
race_color | numeric | 9016192 | 0.8489912 | 1 | 2 | 9 | 4.102821 | 2.829404 | ▇▁▁▁▅ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
cnpj_root | numeric | 0 | 1 | 0 | 8743939 | 1e+08 | 25284192 | 28290971 | ▇▁▂▁▁ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
earn_dec | numeric | 0 | 1 | 0 | 566 | 62253 | 1004.462 | 2030.589 | ▇▁▁▁▁ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
earn_dec_mw | numeric | 0 | 1 | 0 | 1.4 | 150 | 2.417206 | 4.892133 | ▇▁▁▁▁ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
mean_earn | numeric | 0 | 1 | 0 | 711 | 62251 | 1233.433 | 1900.829 | ▇▁▁▁▁ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
mean_earn_mw | numeric | 0 | 1 | 0 | 1.7 | 150 | 3.013137 | 4.669804 | ▇▁▁▁▁ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
hired_wage | numeric | 0 | 1 | 0 | 563 | 1e+07 | 922.0045 | 9638.626 | ▇▁▁▁▁ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
cnae20sub | numeric | 0 | 1 | -1 | 4784900 | 9900800 | 5344825 | 2740978 | ▃▂▇▂▇ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
establishment_size | numeric | 0 | 1 | 0 | 6 | 9 | 5.379538 | 2.818195 | ▃▅▆▅▇ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
tenure | numeric | 0 | 1 | 0 | 16 | 600 | 46.77196 | 73.3376 | ▇▁▁▁▁ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
adm_type | numeric | 0 | 1 | 0 | 0 | 8 | 0.7311843 | 1.017313 | ▇▃▁▁▁ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
firmID_type | numeric | 0 | 1 | 0 | 1 | 1 | 0.9619417 | 0.1913371 | ▁▁▁▁▇ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
wage_type | numeric | 0 | 1 | 1 | 1 | 7 | 1.44253 | 1.278961 | ▇▁▁▁▁ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
disability_type | numeric | 0 | 1 | -1 | 0 | 6 | 0.0148616 | 0.2234134 | ▇▁▁▁▁ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
contract_type | numeric | 0 | 1 | 10 | 10 | 97 | 16.36524 | 13.47509 | ▇▂▁▁▁ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
last_wage | numeric | 0 | 1 | 0 | 1.8 | 150 | 3.331852 | 5.958175 | ▇▁▁▁▁ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
yr | numeric | 0 | 1 | 2008 | 2008 | 2008 | 2008 | 0 | ▁▁▇▁▁ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
termination_year | numeric | 0 | 1 | 2008 | 2008 | 2008 | 2008 | 0 | ▁▁▇▁▁ | NA |
26536715 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
adm_day | numeric | 26536715 | 0.5555467 | 0 | 13 | 99 | 13.66203 | 7.789548 | ▇▃▁▁▁ | NA |
4035409 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
adm_month | numeric | 4035409 | 0.9324125 | 1 | 6 | 19 | 6.018684 | 3.209927 | ▇▇▅▁▁ | NA |
0 missing values.
name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
---|---|---|---|---|---|---|---|---|---|---|
adm_year | numeric | 0 | 1 | 1006 | 2007 | 3012 | 2004.467 | 6.074102 | ▁▁▇▁▁ | NA |
The following JSON-LD can be found by search engines, if you share this codebook publicly on the web.
{
"name": "codebook_data",
"datePublished": "2024-05-31",
"description": "The dataset has N=59706419 rows and 48 columns.\n24506543 rows have no missing values on any column.\n\n\n## Table of variables\nThis table contains variable names, labels, and number of missing values.\nSee the complete codebook for more.\n\n|name |label | n_missing|\n|:------------------|:-----|---------:|\n|adm_date |NA | 0|\n|separation_cause |NA | 0|\n|cei |NA | 0|\n|cnae20 |NA | 105|\n|cnae95 |NA | 0|\n|cpf |NA | 0|\n|termination_day |NA | 0|\n|dob |NA | 0|\n|active1231 |NA | 0|\n|sex |NA | 0|\n|schooling |NA | 0|\n|hired_hours |NA | 0|\n|firmID |NA | 0|\n|alvara_ind |NA | 0|\n|cei_avail |NA | 0|\n|pat |NA | 0|\n|simples |NA | 0|\n|termination_month |NA | 0|\n|muni |NA | 0|\n|nationality |NA | 0|\n|legal_form |NA | 0|\n|name |NA | 0|\n|ctps |NA | 0|\n|cbo02 |NA | 622145|\n|cbo94 |NA | 6423599|\n|pis |NA | 0|\n|disabled |NA | 0|\n|race_color |NA | 9016192|\n|cnpj_root |NA | 0|\n|earn_dec |NA | 0|\n|earn_dec_mw |NA | 0|\n|mean_earn |NA | 0|\n|mean_earn_mw |NA | 0|\n|hired_wage |NA | 0|\n|cnae20sub |NA | 0|\n|establishment_size |NA | 0|\n|tenure |NA | 0|\n|adm_type |NA | 0|\n|firmID_type |NA | 0|\n|wage_type |NA | 0|\n|disability_type |NA | 0|\n|contract_type |NA | 0|\n|last_wage |NA | 0|\n|yr |NA | 0|\n|termination_year |NA | 0|\n|adm_day |NA | 26536715|\n|adm_month |NA | 4035409|\n|adm_year |NA | 0|\n\n### Note\nThis dataset was automatically described using the [codebook R package](https://rubenarslan.github.io/codebook/) (version 0.9.2).",
"keywords": ["adm_date", "separation_cause", "cei", "cnae20", "cnae95", "cpf", "termination_day", "dob", "active1231", "sex", "schooling", "hired_hours", "firmID", "alvara_ind", "cei_avail", "pat", "simples", "termination_month", "muni", "nationality", "legal_form", "name", "ctps", "cbo02", "cbo94", "pis", "disabled", "race_color", "cnpj_root", "earn_dec", "earn_dec_mw", "mean_earn", "mean_earn_mw", "hired_wage", "cnae20sub", "establishment_size", "tenure", "adm_type", "firmID_type", "wage_type", "disability_type", "contract_type", "last_wage", "yr", "termination_year", "adm_day", "adm_month", "adm_year"],
"@context": "http://schema.org/",
"@type": "Dataset",
"variableMeasured": [
{
"name": "adm_date",
"@type": "propertyValue"
},
{
"name": "separation_cause",
"@type": "propertyValue"
},
{
"name": "cei",
"@type": "propertyValue"
},
{
"name": "cnae20",
"@type": "propertyValue"
},
{
"name": "cnae95",
"@type": "propertyValue"
},
{
"name": "cpf",
"@type": "propertyValue"
},
{
"name": "termination_day",
"@type": "propertyValue"
},
{
"name": "dob",
"@type": "propertyValue"
},
{
"name": "active1231",
"@type": "propertyValue"
},
{
"name": "sex",
"@type": "propertyValue"
},
{
"name": "schooling",
"@type": "propertyValue"
},
{
"name": "hired_hours",
"@type": "propertyValue"
},
{
"name": "firmID",
"@type": "propertyValue"
},
{
"name": "alvara_ind",
"@type": "propertyValue"
},
{
"name": "cei_avail",
"@type": "propertyValue"
},
{
"name": "pat",
"@type": "propertyValue"
},
{
"name": "simples",
"@type": "propertyValue"
},
{
"name": "termination_month",
"@type": "propertyValue"
},
{
"name": "muni",
"@type": "propertyValue"
},
{
"name": "nationality",
"@type": "propertyValue"
},
{
"name": "legal_form",
"@type": "propertyValue"
},
{
"name": "name",
"@type": "propertyValue"
},
{
"name": "ctps",
"@type": "propertyValue"
},
{
"name": "cbo02",
"@type": "propertyValue"
},
{
"name": "cbo94",
"@type": "propertyValue"
},
{
"name": "pis",
"@type": "propertyValue"
},
{
"name": "disabled",
"@type": "propertyValue"
},
{
"name": "race_color",
"@type": "propertyValue"
},
{
"name": "cnpj_root",
"@type": "propertyValue"
},
{
"name": "earn_dec",
"@type": "propertyValue"
},
{
"name": "earn_dec_mw",
"@type": "propertyValue"
},
{
"name": "mean_earn",
"@type": "propertyValue"
},
{
"name": "mean_earn_mw",
"@type": "propertyValue"
},
{
"name": "hired_wage",
"@type": "propertyValue"
},
{
"name": "cnae20sub",
"@type": "propertyValue"
},
{
"name": "establishment_size",
"@type": "propertyValue"
},
{
"name": "tenure",
"@type": "propertyValue"
},
{
"name": "adm_type",
"@type": "propertyValue"
},
{
"name": "firmID_type",
"@type": "propertyValue"
},
{
"name": "wage_type",
"@type": "propertyValue"
},
{
"name": "disability_type",
"@type": "propertyValue"
},
{
"name": "contract_type",
"@type": "propertyValue"
},
{
"name": "last_wage",
"@type": "propertyValue"
},
{
"name": "yr",
"@type": "propertyValue"
},
{
"name": "termination_year",
"@type": "propertyValue"
},
{
"name": "adm_day",
"@type": "propertyValue"
},
{
"name": "adm_month",
"@type": "propertyValue"
},
{
"name": "adm_year",
"@type": "propertyValue"
}
]
}`
# } # end year loop