Computes summary statistics from consolidated employment data produced by
the vecshift/longworkR consolidation chain. Employment and unemployment
spells are distinguished via the arco indicator (arco == 1 employment,
arco == 0 unemployment); durations are taken from the durata column.
On consolidated data overlaps are already resolved, so arco takes only
the values 0 and 1.
Value
A named list with elements:
total_records: total number of spellsunique_persons: number of distinctcfvaluestotal_employment_days: sum ofduratafor employment spellstotal_unemployment_days: sum ofduratafor unemployment spellsavg_employment_duration: meandurataof employment spellsavg_unemployment_duration: meandurataof unemployment spells
NA values in durata are ignored (na.rm = TRUE).
Examples
dt <- data.table::data.table(
cf = c("A", "A", "B"),
durata = c(100, 30, 200),
arco = c(1, 0, 1)
)
employment_statistics(dt)
#> $total_records
#> [1] 3
#>
#> $unique_persons
#> [1] 2
#>
#> $total_employment_days
#> [1] 300
#>
#> $total_unemployment_days
#> [1] 30
#>
#> $avg_employment_duration
#> [1] 150
#>
#> $avg_unemployment_duration
#> [1] 30
#>