Dong
March 8, 2019, 7:08am
1
I asked about method to rename factors and the selected answer uses fct_relabel
on the factor vector only.
df$grp = df$grp %>% fct_relabel(str_replace, "_something", "")
But df
in my usage is often the result from tidyr::gather
and I don't feel like breaking the %>%
pipe to name it just to do fct_relabel
, and then resume the pipe. Any suggestions? Thanks!
How about this?
df <- df %>% mutate(grp = fct_relabel(grp, str_replace, "_something", "")) %>% ...
1 Like
Dong
March 8, 2019, 6:15pm
3
Thanks. So simple! I should have looked up how to input the argument from the help :-
fct_relabel(.f, .fun, ...)
system
Closed
March 15, 2019, 6:15pm
4
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.