Home > Net >  How do I re order my plot into a descending order when plotting a single column in factor form?
How do I re order my plot into a descending order when plotting a single column in factor form?

Time:04-08

0

editing out the question to remove now that it's been answered

CodePudding user response:

I'm almost sure you used barplot, just sort the table.

barplot(sort(table(dat$dep_lower), decreasing=TRUE))

enter image description here


Data:

set.seed(216048)
dat <- data.frame(dep_lower=sample(c('beverage', 'entree', 'salad', 'giftcards'),
       50, replace=TRUE))
  •  Tags:  
  • r
  • Related