sort on two variables using ggplot and reorder

We can use paste

ggplot(df_full_short,aes(x=reorder(unit, paste(var1, var2)), y=dev)) + 

Or may be change the unit levels based on the ‘var1’, ‘var2’

df_full_short %>%
         arrange(var1, var2) %>%
         mutate(unit = factor(unit, levels = unique(unit))) %>%
          ggplot(aes(x = unit, y = dev)) + 

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top