Filers often add the dates a person held a position to the title. remove_dates() detects them, sets a DATE.X flag, and strips the date. The words left behind (THRU, UNTIL, SINCE) are read as status qualifiers in step 06.
Before and after
| before (step 01) | after (TitleTxt2) | DATE.X |
|---|---|---|
| BOARD MEMBER (THRU 6/2023) | BOARD MEMBER THRU | 1 |
| TREASURER UNTIL JAN 2023 | TREASURER UNTIL | 1 |
| TRUSTEE (THROUGH 12/2022) | TRUSTEE THROUGH | 1 |
| DIRECTOR TO 5/22 | DIRECTOR TO | 1 |
| PRESIDENT 2021-2023 | PRESIDENT | 1 |
| SECRETARY (RESIGNED 3/16/23) | SECRETARY RESIGNED | 1 |
| 1ST VICE PRESIDENT | FIRST VICE PRESIDENT | 0 |
| 2ND VICE CHAIR | SECOND VICE CHAIR | 0 |
| EXECUTIVE DIRECTOR | EXECUTIVE DIRECTOR | 0 |
What it does
remove_dates()
|
+- convert_ordinal() 1ST/2ND/3RD -> FIRST/SECOND/THIRD
+- has_date() does the string contain a date? -> DATE.X
+- remove_date() strip 'YY, YY-YY, mm/dd/yyyy, month names, trailing numbers
Ordinals are spelled out first, so “1ST VICE PRESIDENT” is not read as a date. The ordinal itself (FIRST, SECOND) is removed later, in step 06.
Assets
| Asset | Type | Used for | Load it with |
|---|---|---|---|
date.words |
word list (package data) | month names and abbreviations that mark a date | data(date.words) |
Try it
x <- c("TREASURER (ENDED 3/16/23)", "DIRECTOR THRU 12/23",
"SECRETARY UNTIL JAN 2023", "PRESIDENT")
data.frame(title = x, has_date = has_date(x), cleaned = remove_date(x))
#> title has_date cleaned
#> 1 TREASURER (ENDED 3/16/23) TRUE TREASURER ENDED
#> 2 DIRECTOR THRU 12/23 TRUE DIRECTOR THRU
#> 3 SECRETARY UNTIL JAN 2023 TRUE SECRETARY UNTIL
#> 4 PRESIDENT FALSE PRESIDENT
convert_ordinal(c("1ST VICE PRESIDENT", "2ND LIEUTENANT GOVERNOR"))
#> [1] "FIRST VICE PRESIDENT" "SECOND LIEUTENANT GOVERNOR"Input: the cleaned title from step 01. Output: TitleTxt2, the title without dates, and the DATE.X flag. Continue with step 03.