I'm trying to produce a string with the specifications (colnames and max string length of each column):
library(tidyverse)
df <- tibble::tribble(
~nif, ~dni_check,
"33333457V", "33333457",
"44817563Q", "44817563",
"33256164G", "33256164",
"36050083K", "36050083"
)
df %>%
summarise(across(everything(), ~ str_c(" C(", max(str_length(.)), ")"))) %>%
map2_chr(colnames(.), ., str_c) %>%
str_c(collapse = "; ")
#> [1] "nif C(9); dni_check C(8)"
Just out of curiosity, would you propose an alternative, maybe in a shorter or neater way?