I have code which converts from wide to long with gather but I have to do this column by column. I want to use pivot_longer to gather wide multiple columns with into multip
I have found the answer to my question:
df3 <- df %>%
tidyr::pivot_longer(cols = c(starts_with("hf"), starts_with("ac"), starts_with("cs"), starts_with("se")),
names_to = c(".value", "level"),
names_pattern = "(.*)_(.*)"
)