get_matching_column_names.Rd
Matching columns are columns whose names start with the given pattern and end with an incrementing integer.
get_matching_column_names(df, pattern)
The dataframe from which to extract columns
The prefix of the column names to extract (string)
A vector of strings that match the pattern
data <- data.frame(week_payment1 = c(1, 2, 3), week_payment2 = c(1, 2, 3),
week_payment3 = c(1, 2, 3), othercolumn = c(5, 6, 7))
get_matching_column_names(data, "week_payment")
#> [1] "week_payment1" "week_payment2" "week_payment3"