Skip to contents

This function translates a vector of ISCO08/ISCO88/ISCO88 codes between different digits. For most surveys, this will be translating between the 4 digit occupations to more general groups, such as three , two and one digit groups.

Usage

isco08_swap(x, from, to)

isco88_swap(x, from, to)

isco68_swap(x, from, to)

Arguments

x

A character vector of 4-digit ISCO08/ISCO88/ISCO88 codes. By 4 digit it means that even though the function could be 3-digits (code 131 for example), the code should be 1310, which is the 4-digit version of ISCO.

from

a numeric specifying the occupation digits of the input vector. Possible values are only 1, 2, 3 or 4.

to

a numeric specifying the desired occupation digits. Possible values are only 1, 2, 3 or 4.

Value

A character vector of ISCO08/ISCO88/ISCO88 codes.

Details

Note that to translate using isco*_swap you'll need to provide the from and to arguments. The first one specifies the current number of digits of the input variable. If your variable is 4-digit occupations, then from should be 4. If you want to translate 4-digit occupations to 3-digits then the arguments should be from = 4 and to = 3. See the argument description of from and to for all possible values. As well as examples on how this works.

This function will accept 4 digit codes as 4 digits. This means that if the 3-digit code is 131 then it should be 1310. All codes should be 4 digits, even though the code is represented as 3-digits (1310, 1320, etc..)

Note that translation can only be done from higher to smaller digits (4 to 3, 3 to 2, 3 to 1) and never the other way around (1 to 2, 2 to 3, 3 to 4).

ISCO68 might return some NAs depending on the occupation code as it does not have 4 digits for the groups 0000 and 1000. Any translation from 4 digit codes to 1 digit codes within those groups will return an NA for those major groups. See the ILO website: https://www.ilo.org/public/english/bureau/stat/isco/isco68/major.htm.

Examples

library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union

# isco08
ess %>%
  transmute(
    isco08,
    isco08_one = isco08_swap(isco08, from = 4, to = 1),
    isco08_two = isco08_swap(isco08, from = 4, to = 2),
    isco08_three = isco08_swap(isco08, from = 4, to = 3),
    isco08_four = isco08_swap(isco08, from = 4, to = 4)
  )
#> # A tibble: 48,285 × 5
#>    isco08 isco08_one isco08_two isco08_three isco08_four
#>    <chr>  <chr>      <chr>      <chr>        <chr>      
#>  1 5414   5000       5400       5410         5414       
#>  2 1321   1000       1300       1320         1321       
#>  3 3135   3000       3100       3130         3135       
#>  4 7131   7000       7100       7130         7131       
#>  5 6111   6000       6100       6110         6111       
#>  6 6111   6000       6100       6110         6111       
#>  7 9313   9000       9300       9310         9313       
#>  8 1311   1000       1300       1310         1311       
#>  9 1311   1000       1300       1310         1311       
#> 10 6111   6000       6100       6110         6111       
#> # ℹ 48,275 more rows

# isco88
ess %>%
  transmute(
    isco88,
    isco88_one = isco88_swap(isco88, from = 4, to = 1),
    isco88_two = isco88_swap(isco88, from = 4, to = 2),
    isco88_three = isco88_swap(isco88, from = 4, to = 3),
    isco88_four = isco88_swap(isco88, from = 4, to = 4)
  )
#> # A tibble: 48,285 × 5
#>    isco88 isco88_one isco88_two isco88_three isco88_four
#>    <chr>  <chr>      <chr>      <chr>        <chr>      
#>  1 5169   5000       5100       5160         5169       
#>  2 1222   1000       1200       1220         1222       
#>  3 8120   8000       8100       8120         8120       
#>  4 7141   7000       7100       7140         7141       
#>  5 6111   6000       6100       6110         6111       
#>  6 6111   6000       6100       6110         6111       
#>  7 9313   9000       9300       9310         9313       
#>  8 1221   1000       1200       1220         1221       
#>  9 1221   1000       1200       1220         1221       
#> 10 6111   6000       6100       6110         6111       
#> # ℹ 48,275 more rows

# isco68
# Note that for certain four digit groups, isco68 does not have a
# major group (0000, 1000). That means that Some NAs might be present,
# such as for occupations that are between 1000 and 200. Remember to
# check well the result.
ess %>%
  transmute(
    isco68,
    isco68_one = isco68_swap(isco68, from = 4, to = 1),
    isco68_two = isco68_swap(isco68, from = 4, to = 2),
    isco68_three = isco68_swap(isco68, from = 4, to = 3),
    isco68_four = isco68_swap(isco68, from = 4, to = 4)
  )
#> # A tibble: 48,285 × 5
#>    isco68 isco68_one isco68_two isco68_three isco68_four
#>    <chr>  <chr>      <chr>      <chr>        <chr>      
#>  1 5890   5000       5800       5890         5890       
#>  2 2120   2000       2100       2120         2120       
#>  3 7200   7000       7200       7200         7200       
#>  4 9310   9000       9300       9310         9310       
#>  5 6220   6000       6200       6220         6220       
#>  6 6220   6000       6200       6220         6220       
#>  7 9595   9000       9500       9590         9595       
#>  8 6000   6000       6000       6000         6000       
#>  9 6000   6000       6000       6000         6000       
#> 10 6220   6000       6200       6220         6220       
#> # ℹ 48,275 more rows