strengejacke / sjlabelled

Working with Labelled Data in R
https://strengejacke.github.io/sjlabelled
86 stars 11 forks source link

add support for tidy select helpers in set_labels #38

Open northeastloon opened 4 years ago

northeastloon commented 4 years ago

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.

iago-pssjd commented 4 years ago

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!

andresimi commented 4 years ago

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

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