knitr::opts_chunk$set(error = TRUE, echo=FALSE, cache=FALSE)
library(ggplot2)
library(SeminarMatching)
library(dplyr)
library(tidyr)
library(reshape2)
setwd("D:/libraries/SeminarMatching/semapps/shared/reports")
semester = "SS16"
db.dir = paste0("../db")
round = 1
semid = 16
semdb = dbConnect(dbname=paste0(db.dir,"/semDB.sqlite"), drv = SQLite())
studpref = dbGet(semdb,"studpref",nlist(semester, semid, round))
if (NROW(studpref)==0) {
  stop("Cannot show seminar report, since no student has yet put the seminar in its preference.",call. = FALSE)
}

matchings = dbGet(semdb,"matchings",nlist(semester, round, semid))
seminars = dbGet(semdb,"seminars",nlist(semester, semid))
students = dbGet(semdb,"students",nlist(semester))

df = studpref
cols = c("semid",setdiff(colnames(seminars),colnames(df)))
df = left_join(df, seminars[,cols,drop=FALSE], by="semid")
cols = c("userid",setdiff(colnames(students),colnames(df)))
df = left_join(df, students[,cols,drop=FALSE], by="userid")
cols = c("semid","userid",setdiff(colnames(matchings),colnames(df)))
df = left_join(df, matchings[,cols,drop=FALSE], by=c("semid","userid"))
df$matched = !is.na(df$slot)

df$Matched = ifelse(df$matched, "matched","not")
seminar = as.list(seminars[1,])


num.prefs = NROW(df)
num.matched = sum(df$matched)

r seminar$semname r semester

This is a report for the main matching round.

The following table shows how many students ranked the seminar at position pos and how many of them were matched to the seminar or not.

sdf = df %>%
  group_by(pos,Matched) %>% 
  summarise(n=n()) %>%
  spread(key = Matched, value=n) %>%
  replace.na(0, cols=-1) %>%
  as.data.frame()

sdf$total = rowSums(sdf[,-1,drop=FALSE],na.rm = TRUE)
sdf

The following table compares students that put the seminar in their preference list by their main subject.

sdf = df %>%
  group_by(studSubject,Matched) %>% 
  summarise(n=n()) %>%
  spread(key = Matched, value=n) %>%
  replace.na(0, cols=-1) %>%
  as.data.frame()

sdf$total = rowSums(sdf[,-1,drop=FALSE],na.rm = TRUE)
sdf = arrange(sdf, -total)
sdf

The following table compares WiWi students that put the seminar in their preference list by their specialization (students with 2 specializations count 1/2 for each specialization):

d = select(df,userid, Matched, studBAMA, studSpecBA, studSpecMA, studSpecMA2)
d = tidyr::gather(d,key = specid,value = spec,studSpecBA, studSpecMA, studSpecMA2)

d = filter(d, 
  (studBAMA=="Bachelor" & specid=="studSpecBA") | 
  (studBAMA=="Master" & specid=="studSpecMA") |
  (studBAMA=="Master" & specid=="studSpecMA2")
)

d = d %>% 
  group_by(userid) %>%
  mutate(weight=1/n())


sdf = d %>%
  group_by(spec,Matched) %>% 
  summarise(n=sum(weight)) %>%
  spread(key = Matched, value=n) %>%
  replace.na(0, cols=-1) %>%
  as.data.frame()

sdf$total = rowSums(sdf[,-1, drop=FALSE],na.rm = TRUE)
sdf = arrange(sdf, -total)
sdf


skranz/SeminarMatching documentation built on June 9, 2020, 6:57 p.m.