Commit 2efb853a authored by Simon Pintarelli's avatar Simon Pintarelli

add checks

TODO: provide meaningful error messages
parent 4dc4db5e
......@@ -130,10 +130,12 @@ library(reshape)
library(xtable)
@
<<prepare data, echo=FALSE, message=FALSE, warning=FALSE>>=
<<prepare data, echo=FALSE, error=TRUE>>=
## read data
dset <- read.csv('marks.csv', encoding='ISO-8859-1')
dset <- dset[, !(names(dset) %in% c("Last.Name", "First.Name"))]
stopifnot(length(dset)-1 == length(max_points_per_task))
dset <- melt(dset, id=c("Number"))
dset$value <- as.numeric(dset$value)
total_points <- group_by(dset, Number) %>% summarize(s=sum(value))
......@@ -149,7 +151,7 @@ colnames(scale_plot) <- c("s", "grade", "col")
scale_plot <- rbind(scale_plot, cbind(scale, col=rep("rounded", nrow(linscale))))
@
<<store grades, echo=FALSE, warning=FALSE>>=
<<store grades, echo=FALSE, warning=FALSE, error=TRUE>>=
## export (legi, grade) to csv
write.csv(data.frame(Number=grades$legi, Grade=grades$grade, Points=grades$point),
fileEncoding='ISO-8859-1',
......@@ -160,7 +162,7 @@ write.csv(data.frame(Number=grades$legi, Grade=grades$grade, Points=grades$point
\section*{Grades}
\label{sec:grades}
<<grades, echo=FALSE, warning=FALSE, fig.width=5, fig.height=5, out.width="0.49\\linewidth", fig.show='hold', fig.env="figure*", fig.subcap=c("Histogram", "CDF"), fig.pos='h!'>>=
<<grades, echo=FALSE, warning=FALSE, error=TRUE, fig.width=5, fig.height=5, out.width="0.49\\linewidth", fig.show='hold', fig.env="figure*", fig.subcap=c("Histogram", "CDF"), fig.pos='h!'>>=
ggplot(grades, aes(x=grade)) +
geom_histogram(binwidth = 0.25, alpha=0.8) +
scale_x_continuous(breaks=seq(1,6, by=1)) +
......@@ -172,7 +174,7 @@ ggplot(grades, aes(x=grade)) +
@ %def
<<violing, echo=FALSE, fig.height=1, fig.width=3, fig.show='hold'>>=
<<violing, echo=FALSE, error=TRUE, fig.height=1, fig.width=3, fig.show='hold'>>=
ogrades <- cbind.data.frame(x=rep("grade", nrow(grades)), y=grades$grade)
opoints <- cbind.data.frame(x=rep("points", nrow(grades)), y=grades$points)
ggplot(ogrades, aes(x=x,y=y)) +
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment