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 = "SS17" db.dir = paste0("../db") semid = 17 semdb = dbConnect(dbname=paste0(db.dir,"/semDB.sqlite"), drv = SQLite())
studpref = dbGet(semdb,"studpref",nlist(semester, semid)) if (NROW(studpref)==0) { stop("Cannot show seminar report, since no student has yet put the seminar in its preference.",call. = FALSE) } 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") seminar = as.list(seminars[1,]) num.prefs = NROW(df)
r seminar$semname
r semester
A total of r num.prefs
students have put the seminar in their preference list. Your seminar has r seminar$slots
slots.
The following table shows how many students ranked the seminar at position pos
.
df$pos = ifelse(df$pos <=3, df$pos, "4 or larger") sdf = df %>% group_by(pos) %>% summarise(n=n()) %>% arrange(pos) sdf
The following table compares students that put the seminar in their preference list by their main subject and randked position
sdf = df %>% group_by(studSubject,pos) %>% summarise(n=n()) %>% spread(key = pos, value=n) %>% replace.na(0, cols=-1) %>% as.data.frame() sdf$total = rowSums(sdf[,-1,drop=FALSE],na.rm = TRUE) sdf = arrange(sdf, -total) %>% select(studSubject, total, everything()) 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, studBAMA, studSpecBA, studSpecMA, studSpecMA2, pos) d = tidyr::gather(d,key = specid,value = spec,studSpecBA, studSpecMA, studSpecMA2) %>% filter(spec!="-") 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,pos) %>% summarise(n=sum(weight)) %>% spread(key = pos, value=n) %>% replace.na(0, cols=-1) %>% as.data.frame() sdf$total = rowSums(sdf[,-1, drop=FALSE],na.rm = TRUE) sdf = arrange(sdf, -total) %>% select(spec, total, everything()) sdf
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.