-v <- paste(y,"-baaaarplot.png",sep="")
-png(v, width=8, height=6, unit="in", res=200)
-p <- qplot(day.of.week, data=d, fill=as.factor(rating), main=y)
-#p <- qplot(levels(d$day.of.week),as.factor(names(d$rating)), t, data=data.frame(t,levels(d$day.of.week)))
-p <- p + scale_x_discrete("Day of Week") + scale_y_continuous("yelp # star review") + scale_fill_discrete("")
+
+# generate the unscaled count graph
+filename.count <- paste(y,"-count-png",sep="")
+
+png(filename.count, width=8, height=6, unit="in", res=200)
+p <- qplot(day.of.week, data=d, fill=as.factor(rating), geom="bar", main=y)
+p <- p + scale_x_discrete("Day of Week") +
+ scale_y_continuous("yelp # star review") +
+ scale_fill_discrete("", breaks=as.character(rev(1:5)) )
+print(p)
+dev.off()
+
+# generate the scaled proportion graph
+filename.prop <- paste(y,"-proportion-png",sep="")
+
+max.value <- tapply(d$plot.weight, d$day.of.week, sum)[1]
+
+p <- qplot(day.of.week, data=d, fill=as.factor(rating), geom="bar",
+ weight=plot.weight, main=y)
+p <- p + scale_x_discrete("Day of Week") +
+ scale_y_continuous("percentage of reviews",
+ breaks=(0:4 * max.value/4), labels=seq(0,100, 25)) +
+ scale_fill_discrete("", breaks=as.character(rev(1:5)))