Is it possible to combine the selection types for scoped functions?

Hi,

Is it possible to combine the selection types for scoped functions? For example, I would like to convert mostly all character columns to upper case, but excluding some of them.

df <- 
  df %>% 
  mutate_if(is.character, -colA, -colD, toupper)

df <- 
  df %>% 
  mutate_if(is.character, -vars(ends_with("_lower"), toupper)

Do you have any better (tidier) solution than to create separately a list/vector of column names and use the mutate_at(vars())?

Thank you for your help.

Not currently, but we're thinking about some re-unification of the _if() and _at() functions so that one day you'll be able to write something like:

df %>% 
  mutate_at(c(is.character, -colA, -colD), toupper)
2 Likes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.