I think many users, probably particular those with less experience in R and the tidyverse like myself, can benefit if the documentation for most of forcats functions would include an example of piping a function to dplyr::mutate when working with data.frames.
I think it is a small thing that can save some frustration for people new to forcats.
For example:
df <- tibble(f = factor(c("a", "b", "c", "d"),
levels = c("b", "c", "d", "a")))
## this code fails
df %>%
fct_relevel(f, "a") %>%
str()
## this code works as expected.
df %>%
mutate(f = fct_relevel(f, "a")) %>%
str()
This is a good idea, but unfortunately we can't do it because it would require dplyr to be a dependency of forcats, which unfortunately is a bad idea for software engineering reasons.
Hi!
I think many users, probably particular those with less experience in R and the tidyverse like myself, can benefit if the documentation for most of forcats functions would include an example of piping a function to dplyr::mutate when working with data.frames. I think it is a small thing that can save some frustration for people new to forcats.
For example: