'How can I plot a grouped barplot in ggplot based on frequency?

I want to plot a grouped barplot with the values avg_r and price_l , but based on the frequency of price_l. I tried something like this:

g1 <- ggplot(sub.dt, aes(fill=price_l, y=seq(0,24,1), x=avg_r)) + 
  geom_bar(position="dodge", stat="identity")

g1

Which gives me that:

enter image description here

So, for example 2.5 should be at 1 at the y axis. Here is some code for reproduction:

price_l <- c('€€-€€€', '€€-€€€', '€€€€', '€€-€€€', '€€-€€€', 
             '€€-€€€', '€€€€', '€€-€€€', '€€€€', '€€-€€€', 
             '€€-€€€', '€€-€€€', '€€-€€€', '€€-€€€', 
             '€€-€€€', '€€-€€€', '€€-€€€', '€€-€€€', '€€€€','€', '€', 
             '€', '€','€€€€', '€')

avg_r <- c('4.5', '3.5', '4.0', '4.0', '4.0', '3.5', '4.5', '4.0', '3.0', '4.0', 
           '3.0', '5.0', '4.5', '4.0', '3.0',
           '3.5', '4.5', '3.5', '3.5', '4.0', '3.0', '4.0', '4.0', '2.5', '4.5')
             
sub.dt <- data.table(price_l, avg_r)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source