Helper function: call tidyr::gather for year-like columns and convert them to integers

gather_years(
  d,
  value_col = "value",
  year_pattern = YEAR_PATTERN,
  na.rm = FALSE
)

Arguments

d

Data frame to operate on (a tibble)

value_col

Name of the resulting (gathered) value column, string or unquoted column name

year_pattern

Year pattern to match against

na.rm

Remove NAs flag passed on to tidyr::gather

Value

The gathered (reshaped) data frame.