Skip to contents

With the separators reduced to &, split_titles() turns a row that holds several roles into one row per role. The person’s name, pay, hours and checkboxes repeat on each row; Num.Titles numbers the rows. A few common pairs are collapsed to one title rather than split: “PRESIDENT & CEO” is a CEO.

Before and after

person before (TitleTxt3) after (TitleTxt4) Num.Titles
PERSON 01 SEC & TREAS SEC 1
PERSON 01 SEC & TREAS TREAS 2
PERSON 02 BOARD MEMBER & TREASURER BOARD MEMBER 1
PERSON 02 BOARD MEMBER & TREASURER TREASURER 2
PERSON 03 CHIEF EXEC OFFICER & FOUNDER CHIEF EXEC OFFICER 1
PERSON 03 CHIEF EXEC OFFICER & FOUNDER FOUNDER 2
PERSON 04 EVP & COO EVP 1
PERSON 04 EVP & COO COO 2
PERSON 05 PRESIDENT & CEO CEO 1
PERSON 06 TRUSTEE & TREASURER TRUSTEE 1
PERSON 06 TRUSTEE & TREASURER TREASURER 2
PERSON 07 FOUNDER & EXECUTIVE DIRECTOR FOUNDER 1
PERSON 07 FOUNDER & EXECUTIVE DIRECTOR EXECUTIVE DIRECTOR 2
PERSON 08 VP FINANCE AND ADMINISTRATION VP FINANCE AND ADMINISTRATION 1
PERSON 09 EXECUTIVE DIRECTOR EXECUTIVE DIRECTOR 1

Nine people become 15 rows.

What it does

split_titles()
|
+- apply_misc_split_rules()  fixes for edge cases (PRESIDENT & CEO -> CEO, ...)
+- identify_split_num()      how many titles does the string hold?
+- remove_first_split()      peel off the text before the first "&", repeat

Later steps work on one title per row. The person-level view comes back in step 08, which counts each person once (title.count, title.order), and step 09, which gives each person one role.

Assets

Step 04 uses no crosswalk or word list: it relies on the & separators that step 03 wrote.

Try it

identify_split_num("CFO & TREASURER & DIRECTOR")   # 3
#> [1] 3
remove_first_split("CFO & TREASURER & DIRECTOR")   # " TREASURER & DIRECTOR"
#> [1] " TREASURER & DIRECTOR"
data(tinypartvii)
d <- dplyr::sample_n(tinypartvii, 120)
df <- d |> standardize_df() |> remove_dates() |> standardize_conj() |> split_titles()
#> [OK] standardize df step complete
#> [OK] remove dates step complete
#> [OK] standardize conjunctions step complete
#> [OK] split titles step complete
df |>
  dplyr::filter(grepl("&", TitleTxt3)) |>
  dplyr::select(F9_07_COMP_DTK_NAME_PERS, Num.Titles, TitleTxt3, TitleTxt4) |>
  head(8)
#>      F9_07_COMP_DTK_NAME_PERS Num.Titles             TitleTxt3 TitleTxt4
#> 51                                     1  TREASURER & YMCA CFO TREASURER
#> 51.1                                   2  TREASURER & YMCA CFO  YMCA CFO
#> 71              ANNA ALVARADO          1 SECRETARY & TREASURER SECRETARY
#> 71.1            ANNA ALVARADO          2 SECRETARY & TREASURER TREASURER
#> 96         RABBI DANIEL ZARET          1       PRESIDENT & CEO       CEO

Input: TitleTxt3. Output: one row per title, with the single title in TitleTxt4 and its position within the person’s entry in Num.Titles. Continue with step 05.