Step 06 - Generate status codes
Source:vignettes/step-06-gen-status-codes.Rmd
step-06-gen-status-codes.RmdMany titles carry a qualifier about the person’s status in the role: FORMER, INTERIM, PRESIDENT-ELECT, EX OFFICIO, AT LARGE, CO-CHAIR. The qualifier matters for analysis (an interim CEO, a past president) but would split one title into many crosswalk entries. gen_status_codes() detects each qualifier, records it as a 0/1 flag, and removes it from the title, or, for a few that change the role, keeps a standard form.
Before and after
| before (TitleTxt5) | after (TitleTxt6) | flags set |
|---|---|---|
| FORMER CFO | CFO | FORMER.X |
| ACTING CFO | CFO | INTERIM.X |
| INTERIM EXECUTIVE DIRECTOR | EXECUTIVE DIRECTOR | INTERIM.X |
| PRESIDENT-ELECT | PRESIDENT | FUTURE.X |
| PAST PRESIDENT | PRESIDENT | FORMER.X |
| OUTGOING TREASURER | TREASURER | OUTGOING.X |
| EMERITUS TRUSTEE | TRUSTEE | FORMER.X |
| BOARD MEMBER THRU | BOARD MEMBER | OUTGOING.X |
| TRUSTEE EXOFFICIO | TRUSTEE | EXOFFICIO.X |
| MEMBER AT LARGE | MEMBER | AT.LARGE.X |
| CO-CHAIR | CHAIR | CO.X |
| FIRST VICE PRESIDENT | VICE PRESIDENT | |
| REGIONAL DIRECTOR | REGIONAL DIRECTOR | REGIONAL.X |
| FOUNDER | FOUNDER | FOUNDER.X |
| EXECUTIVE DIRECTOR | EXECUTIVE DIRECTOR | FOUNDER.X |
| TREASURER | TREASURER |
A person’s flags apply to all of their titles: in “FOUNDER & EXECUTIVE DIRECTOR”, both rows carry FOUNDER.X.
What it does
gen_status_codes()
|
+- remove number words and ordinals (FIRST, SECOND, ...)
+- flag_and_keep() flag, write one standard form: EXOFFICIO, REGIONAL
+- flag_and_remove() flag, delete the qualifier: FORMER, FOUNDER, FUTURE, INTERIM,
| OUTGOING, PARTIAL, SCHED O, AT LARGE
+- get_variants() all the spellings of one status, as one regular expression
+- share flags across a person's rows
+- clean up drop a trailing EXOFFICIO, a CO- prefix (flag CO.X), NON-VOTING,
stray parentheses and punctuation
- REGIONAL stays in the title, because a regional director is a different job. EXOFFICIO stays only when it is the whole title (EXOFFICIO BOARD MEMBER).
-
PARTIALmarks a partial year: a date in the title, or an outgoing, future or part-year status. - A title with both FORMER and FUTURE (“from … until”) keeps FORMER only.
The flags become former.x, interim.x, future.x, outgoing.x, partial.x, ex.officio.x, at.large.x, co.x, region.x, founder.x, sched.o.x and date.x in the final output. The Taxonomy article defines each one.
Assets
| Asset | Type | Used for | Load it with |
|---|---|---|---|
status.codes |
crosswalk (package data) | maps each qualifier spelling (status.variant) to its status (status.qualifier) |
get_status_codes() or data(status.codes)
|
number.words |
word list (package data) | number words and ordinals to remove | data(number.words) |
The crosswalk’s source is data-raw/crosswalks/status-codes.csv in the source repository.
sc <- get_status_codes()
dim(sc)
#> [1] 294 2
table(sc$status.qualifier)
#>
#> AT LARGE CURRENT EXOFFICIO FORMER FOUNDER FUTURE INTERIM OUTGOING
#> 5 1 4 14 4 30 6 33
#> PARTIAL REGIONAL SCHED O
#> 10 182 5
head(sc[sc$status.qualifier == "INTERIM", ], 10)
#> status.variant status.qualifier
#> 59 INT INTERIM
#> 60 INTERIM INTERIM
#> 61 PRESENT INTERIM
#> 62 ACTING INTERIM
#> 63 TEMP INTERIM
#> 64 TEMPORARY INTERIMTry it
get_variants("FORMER", sc) # all the spellings of FORMER, as one regex
#> [1] "\\bCEASED\\b|\\bDECEASED\\b|\\bEMERITUS\\b|\\bFORMER\\b|\\bFRMR\\b|\\bIMMED PAST\\b|\\bIMMEDIATE\\b|\\bIMMEDIATE PA\\b|\\bIMMEDIATE PAST\\b|\\bPAST\\b|\\bIMMED PAST\\b|\\bPREVIOUS\\b|\\bPRIOR\\b|\\bRETIRED\\b"
x <- c("IMMEDIATE PAST CHAIR", "OUTGOING CEO", "ACTING DIRECTOR", "TREASURER")
remove_status(x, get_variants("FORMER", sc))
#> [1] " CHAIR" "OUTGOING CEO" "ACTING DIRECTOR" "TREASURER"
remove_status(x, get_variants("INTERIM", sc))
#> [1] "IMMEDIATE PAST CHAIR" "OUTGOING CEO" " DIRECTOR"
#> [4] "TREASURER"Input: TitleTxt5. Output: TitleTxt6, without status qualifiers, and one flag per status. Continue with step 07.