strengejacke / sjlabelled

Working with Labelled Data in R

Home Page:https://strengejacke.github.io/sjlabelled

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

add support for tidy select helpers in set_labels

northeastloon opened this issue · comments

set_labels appears to only offer limited support for tidy select helpers. While 'çontains' and 'starts_with', work, others such as 'any_of', 'where' and 'matches' are not recognised.

I was going to ask something related, but for var_labels, if not implemented yet. The recent update dplyr 1.0.0 has come with the new function across, with which we could do something like:

... %>%
   var_labels(across(c(a set of variables), ~function on (.)))

which would be very useful if from the variables we could get their names.

Thank you!

Actually, I found it is possible to work with across like this:

data %>%
  mutate(across(starts_with("MDD"), ~sjlabelled::set_label(.,  "Depression")))