I'm plotting a simple barplor using ggplot2 using data from the "Digital News Report". Here's my data:
media <- c("Online", "TV", "Print", "Social Media")
perc <- c(89,75,40,71)
data <- data.frame(cbind(media,perc))
And here's my plot
library(tidyverse)
ggplot(data, aes(media,perc))+
geom_bar(stat = "identity")+
coord_flip()+
theme_classic()
I want to order it in a decreasing way and I can do it like this:
data$media <- factor(data$media, levels = c('Print','Social Media','TV', 'Online'))
But I'm lookinf for a faster way to do it (especially when I've to work with more categories).