Reputation: 15382
Related: Difference of fct_reorder and reorder
Consider the code below from here and here.
My question:
arrange(desc(Median))
if there is an fct_reorder(Major, Median)
beneath it?library(tidyverse)
recent_grads <- read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2018/2018-10-16/recent-grads.csv")
majors_processed <- recent_grads %>%
arrange(desc(Median)) %>% # What is the benefit of doing this if we have an fct_reorder below and vice-versa? Don't they do the same thing?
mutate(Major = str_to_title(Major),
Major = fct_reorder(Major, Median))
majors_processed %>%
View()
Upvotes: 0
Views: 620
Reputation: 15382
As @Axeman noted:
arrange
reorders rows.fct_reorder
reorders factor levels. They are principally different things. Note that after thearrange
one could just as well usefct_inorder
instead offct_reorder
.
Upvotes: 2