This is an extension of the already discussed question (I am copying the perfect data example and solution by jakub from https://stackoverflow.com/a/18162330 )
Data:
raw <- read.csv("http://pastebin.com/raw.php?i=L8cEKcxS",sep=",")
raw[,2]<-factor(raw[,2],levels=c("Verygood","Bad","Good","VeryGood"),ordered=FALSE)
raw[,3]<-factor(raw[,3],levels=c("Very Bad","Bad","Good","Very Good"),ordered=FALSE)
raw[,4]<-factor(raw[,4],levels=c("Very Bad","Bad","Good","Very Good"),ordered=FALSE)
raw=raw[,c(2,3,4)]
freq=table(col(raw), as.matrix(raw)) # get the counts of each factor level
ggplot + mutliple grouping bar
Names=c("Food","Music","People") # create list of names
data=data.frame(cbind(freq),Names) # combine them into a data frame
data=data[,c(5,3,1,2,4)] # sort columns
# melt the data frame for plotting
data.m <- melt(data, id.vars='Names')
# plot everything
ggplot(data.m, aes(Names, value)) +
geom_bar(aes(fill = variable), position = "dodge", stat="identity")
The only addition I am struggling to make is to add a fitted line (third degree polynomial) to show the trend for each category as variable changes from "very bad" to "very good"
Plotting the trend seems to be an issue.