Commit cacd5258 authored by Simon Pintarelli's avatar Simon Pintarelli

add study direction to data file

parent de0026ea
......@@ -11,7 +11,7 @@ import pandas as pa
import argparse
import os
selected_columns = ['Number', 'Last Name', 'First Name']
selected_columns = ['Number', 'Last Name', 'First Name', 'Direction']
# header_de = [
# 'Id', 'Familienname', 'Vorname', 'Nummer', 'Sekretariat', 'Fachrichtung',
......@@ -26,11 +26,11 @@ selected_columns = ['Number', 'Last Name', 'First Name']
# skip unneeded columns
header_de = [
'Familienname', 'Vorname', 'Nummer'
'Familienname', 'Vorname', 'Nummer', 'Fachrichtung'
]
header_en = [
'Last Name', 'First Name', 'Number'
'Last Name', 'First Name', 'Number', 'Direction'
]
......
......@@ -39,12 +39,11 @@ dg <- 0.25 # grade interval
## it is assumed that they map to grade 1 or 6 respectively.
int_points <- c(0, maxpoints)
int_grades <- c(1, 6)
@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ================= END USER SETTINGS =================== %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<<<check_user_settings, echo=FALSE, error=TRUE>>=
if(min(int_points) > 0){
int_grades <- c(1, int_grades)
......@@ -134,26 +133,23 @@ library(xtable)
## 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))
stopifnot(length(dset)-2 == length(max_points_per_task))
dset <- melt(dset, id=c("Number"))
dset <- melt(dset, id=c("Number", "Direction"))
dset$value <- as.numeric(dset$value)
total_points <- group_by(dset, Number) %>% summarize(s=sum(value))
linscale <- data.frame(approx(int_points, int_grades, seq(0, maxpoints, by=dp)))
# join grading scale with total_points by using an auxiliary column with integer values
FUZZY <- 1e6
linscale$jj <- as.integer(round(linscale$x*FUZZY))
scale <- data.frame(grade=floor(linscale$y*1/dg)*dg, jj=linscale$jj)
# add integer column to total_points
total_points$jj <- as.integer(round(total_points$s*FUZZY))
grades <- data.frame(left_join(x=total_points, y=scale, by="jj"))
grades <- grades[,c("Number", "s", "grade")]
colnames(grades) <- c("legi", "points", "grade")
grades$legi <- as.factor(grades$legi)
## plot grading scale (linear interpolation and projection to existing marks)
scale_plot <- cbind(linscale, col=rep("linear interpolation", nrow(linscale)))
colnames(scale_plot) <- c("s", "grade", "jj", "col")
scale$s <- scale$jj/FUZZY
scale_plot <- rbind(scale_plot, cbind(scale, col=rep("rounded", nrow(linscale))))
@
<<store grades, echo=FALSE, warning=FALSE, error=TRUE>>=
......@@ -169,15 +165,16 @@ write.csv(data.frame(Number=grades$legi, Grade=grades$grade, Points=grades$point
\label{sec:grades}
<<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 = dg, alpha=0.8) +
scale_x_continuous(breaks=seq(1,6, by=1)) +
coord_cartesian(xlim=c(1,6)) +
ylab("Num. Stud")
geom_histogram(binwidth = dg, alpha=0.8) +
scale_x_continuous(breaks=seq(1,6, by=1)) +
coord_cartesian(xlim=c(1,6)) +
ylab("Num. Stud")
ggplot(grades, aes(x=grade)) +
stat_ecdf() +
scale_x_continuous(breaks=seq(1,6, by=1)) +
coord_cartesian(xlim=c(1,6)) +
ylab("Percentage")
stat_ecdf() +
scale_x_continuous(breaks=seq(1,6, by=1)) +
coord_cartesian(xlim=c(1,6)) +
ylab("Percentage")
@ %def
......@@ -202,6 +199,11 @@ ggplot(opoints, aes(x=x,y=y)) +
<<grading_scale_plot, opts.label="codefig", echo=FALSE, results='asis', cache=FALSE, fig.width=5, fig.height=5>>=
## plot grading scale (linear interpolation and projection to existing marks)
scale_plot <- cbind(linscale, col=rep("linear interpolation", nrow(linscale)))
colnames(scale_plot) <- c("s", "grade", "jj", "col")
scale$s <- scale$jj/FUZZY
scale_plot <- rbind(scale_plot, cbind(scale, col=rep("rounded", nrow(linscale))))
I <- match(seq(min(int_grades), max(int_grades), by=dg), scale$grade)
plot1 <- ggplot(scale_plot, aes(x=s, y=grade, col=col)) +
geom_line() +
......@@ -266,3 +268,9 @@ ggplot(total_points, aes(x=s)) +
\end{document}
% Local Variables:
% font-latex-fontify-script: nil
% End:
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