Skip to content

Instantly share code, notes, and snippets.

@briatte
Created October 15, 2013 13:50
Show Gist options
  • Save briatte/6991871 to your computer and use it in GitHub Desktop.
Save briatte/6991871 to your computer and use it in GitHub Desktop.
R script to check grades
## grade checks
setwd("...")
data = dir(pattern = ".txt")
data = lapply(data, function(x) {
g = as.numeric(substr(x, 1, 1))
l = readLines(x)
n = l[grepl("Note indicative", l)]
n = as.numeric(gsub("Note indicative : | / 20", "", n))
n1 = l[grepl("instructions de rendu et orthographe", l)]
n1 = suppressWarnings(as.numeric(substr(n1, 63, 63)))
n2 = l[grepl("structure du texte et articulation des arguments", l)]
n2 = suppressWarnings(as.numeric(substr(n2, 70, 70)))
n3 = l[grepl("texte concis, équilibré et illustré", l)]
n3 = suppressWarnings(as.numeric(substr(n3, 70, 72)))
if(!length(n)) {
n = n1 = n2 = n3 = 0
warning(x, ": zero grade")
}
if(!is.na(n) & (n != n1 + n2 + n3)) {
warning(x, ": sum error")
}
data.frame(id = gsub("[0-9|_]|.txt", "", x), groupe = g, note = n, n1, n2, n3)
})
data = plyr::rbind.fill(data)
d = na.omit(data)
d = subset(d, groupe > 0)
head(d)
tail(d)
nrow(d)
table(d$note < 10, d$groupe, exclude = NULL)
aggregate(note ~ groupe, summary, data = d)
aggregate(n1 ~ groupe, summary, data = d)
aggregate(n2 ~ groupe, summary, data = d)
aggregate(n3 ~ groupe, summary, data = d)
library(ggplot2)
den = qplot(data = subset(d, note > 0), x = note,
colour = factor(groupe), geom = "density") +
geom_rug() +
scale_x_continuous(limits = c(0, 20)) +
scale_colour_brewer("Groupe", palette = "Set1") +
theme_minimal()
den
box = qplot(data = subset(d, note > 0), y = note, x = factor(groupe),
colour = factor(groupe), geom = "violin") +
stat_summary(fun.data = "mean_cl_boot") +
scale_y_continuous(limits = c(0, 20)) +
scale_colour_brewer("Groupe", palette = "Set1") +
theme_minimal() +
coord_flip()
box
## bye
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment