Skip to contents

Return section headers according to splitting variables specified

Usage

split_section_headers(
  datain,
  split_by = "",
  split_by_prefix = "",
  split_lab = " ",
  sep = "~"
)

Arguments

datain

Input data

split_by

Variables to split data by (used if split_by_prefix is "")

split_by_prefix

Prefix to identify splitting variables

split_lab

Text to prefix the section values with

sep

Separating character if multiple split_by are present

Value

list of dataframe(s)

Examples


library(dplyr)
data(adsl)

adsl |>
  mutate(SUBGRPVAR1 = SEX, SUBGRPVAR2 = AGEGR1) |>
  split_section_headers(
    split_by = "",
    split_by_prefix = "SUBGRPVAR",
    split_lab = "Group:~Age Group",
    sep = " & "
  )
#> [1] "Group:F & Age Group65-80" "Group:F & Age Group<65"  
#> [3] "Group:F & Age Group>80"   "Group:M & Age Group65-80"
#> [5] "Group:M & Age Group<65"   "Group:M & Age Group>80"  

iris |>
  split_section_headers("Species", split_lab = "Name of species:")
#> [1] "Name of species:setosa"     "Name of species:versicolor"
#> [3] "Name of species:virginica"