Have spent a lot of time on this so hoping someone can advise. I have a piece of code that used funs(), which is soft deprecated and so have tried the alternative but cannot get it to work as expected.
Old:
df %>% mutate_at(vars(x,y,z),
.funs = funs(Comment = case_when(
.%in% "YES") ~ deparse(substitute(.))))
This gives the three new variables: x_Comment, y_Comment & z_Comment - and will contain the relevant variable name ("x", "y" or "z") if the relevant variable contains "YES"
Updated:
df %>% mutate_at(vars(x,y,z),
.funs = list(Comment = ~case_when(
.%in% "YES") ~ deparse(substitute(.))))
I have updated the code based on the warnings about funs() being soft deprecated however the above doesn't work. It gives the three new variables as expected: x_Comment, y_Comment & z_Comment - however if the relevant variable contains "YES" it give "." instead of the variable name.
Any solutions - preferably tidyverse very much so appreciated!
Thanks!