0

I provided an image of the code I already have, but how do I make it in descending order?

enter image description here

Dan Adams
  • 4,971
  • 9
  • 28
  • 3
    It's easier to help you if you include a simple reproducible example: with sample input and desired output that can be used to test and verify possible solutions. – TarJae Apr 12 '22 at 20:43
  • 2
    library(forcats) fct_reorder() https://forcats.tidyverse.org/reference/fct_reorder.html – Susan Switzer Apr 12 '22 at 20:46

1 Answers1

4
df <- data.frame(
  stringsAsFactors = FALSE,
          type = c('Ave', 'Blvd', 'Cirle', 'Court', 'Dr'),
              total = c(254, 25, 30, 35, 550)
)

ggplot(data = df, 
       mapping = aes(x = fct_reorder(type, total),  y = total)) +
  geom_bar(stat = 'identity', fill = '#112446')+
  theme_bw()

sample

add .desc = TRUE to fct_reorder for descending

ggplot(data = df, 
       mapping = aes(x = fct_reorder(type, total,  .desc = TRUE),  y = total)) +
  geom_bar(stat = 'identity', fill = '#112446')+
  theme_bw()

sample

Susan Switzer
  • 1,531
  • 8
  • 34