Categorical Data in the Tidyverse
Emily Robinson
Data Scientist
ggplot(aes(nlp_frequency,
x = fct_relevel(response,
"Rarely", "Sometimes", "Often", "Most of the time"))) +
geom_bar()
nlp_frequency %>%
pull(response) %>%
levels()
[1] "Most of the time" "Often" "Rarely" "Sometimes"
nlp_frequency %>%
mutate(response = fct_relevel(response,
"Often", "Most of the time")) %>%
pull(response) %>%
levels()
[1] "Often" "Most of the time" "Rarely" "Sometimes"
nlp_frequency %>%
mutate(response = fct_relevel(response,
"Often", "Most of the time", after = 2)) %>%
pull(response) %>%
levels()
nlp_frequency %>%
mutate(response = fct_relevel(response,
"Often", "Most of the time", after = Inf) %>%
pull(response) %>%
levels()
[1] "Rarely" "Sometimes" "Often" "Most of the time"
Categorical Data in the Tidyverse