How to make frequency barplot in groups?

Viewed 7513

Suppose my data is two columns, one is "Condition", one is "Stars"

food <- data.frame(Condition = c("A", "B", "A", "B", "A"), Stars=c('good','meh','meh','meh','good'))

How to make a barplot of the frequency of "Star" as grouped by "Condition"?

I read here but would like to expand that answer to include groups.

for now I have

q <- ggplot(food, aes(x=Stars))
q + geom_bar(aes(y=..count../sum(..count..)))

enter image description here but that is the proportion of the full data set.

How to make a plot with four bars, that is grouped by 'Condition'?

Eg. 'Condition A' would have 'Good' as 0.66 and 'Meh' as 0.33

2 Answers
Related