table(d$num.calls, d$absences)
-## png("questions_absence_histogram_combined.png", units="px", width=600, height=400)
+png("questions_absence_histogram_combined.png", units="px", width=600, height=400)
ggplot(d) +
aes(x=as.factor(num.calls), fill=as.factor(absences)) +
scale_fill_manual("Absences", values=color.gradient) +
theme_bw()
-## dev.off()
+dev.off()
absence.labeller <- function (df) {
lapply(df, function (x) { paste("Absences:", x) })
## png("questions_absence_histogram_facets.png", units="px", width=600, height=400)
-ggplot(d) +
- aes(x=as.factor(num.calls)) +
- geom_bar() +
- stat_count() +
- scale_x_discrete("Number of questions answered") +
- scale_y_continuous("Number of students") +
- theme_bw() +
- facet_wrap(.~absences, ncol=5, labeller="absence.labeller")
+## ggplot(d) +
+## aes(x=as.factor(num.calls)) +
+## geom_bar() +
+## stat_count() +
+## scale_x_discrete("Number of questions answered") +
+## scale_y_continuous("Number of students") +
+## theme_bw() +
+## facet_wrap(.~absences, ncol=5, labeller="absence.labeller")