这是已经讨论的问题的扩展(我正在通过jakub从https://stackoverflow.com/a/18162330复制完美的数据示例和解决方案)
数据:
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分组栏
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")
我正在努力做的唯一补充就是添加一条拟合线(三次多项式)来显示每个类别的趋势,从“非常糟糕”变为“非常好”
绘制趋势似乎是一个问题。