R/add_max_chars_labels_to_chapter_structure.R

Defines functions add_max_chars_labels_to_chapter_structure

add_max_chars_labels_to_chapter_structure <-
  function(chapter_structure,
           target_variable = ".variable_label_suffix_dep",
           variable_name_max_label_char = ".max_chars_labels_dep") {
    if (is.null(chapter_structure[[target_variable]])) {
      cli::cli_abort("{.arg target_variable} ({.var {target_variable}}) not found in {.arg chapter_structure}.")
    }

    chapter_structure |>
      dplyr::mutate("{variable_name_max_label_char}" := max(c(nchar(.data[[target_variable]]), 0), na.rm = TRUE))
  }

Try the saros.base package in your browser

Any scripts or data that you put into this service are public.

saros.base documentation built on June 8, 2025, 10:03 a.m.