################################################### classData <- read.csv("Data/transcripts-blind.csv", stringsAsFactors=FALSE, strip.white=TRUE) ################################################### classData$Current <- classData$Term > 1090 ################################################### subjNumbers <- read.table("Data/subjectNumbers.txt", sep="\t", col.names=c("SubjectNumber", "SubjectName"), stringsAsFactors=FALSE) classData <- merge(classData, subjNumbers, by.x="Subject", by.y="SubjectNumber", all.x=TRUE) classData$SubjectName[is.na(classData$SubjectName)] <- classData$Subject[is.na(classData$SubjectName)] ################################################### schools <- read.table("Data/school.txt", sep="\t", quote="", strip.white=TRUE, stringsAsFactors=FALSE, col.names=c("Subject", "FullName", "School", "EMPTY")) classData <- merge(classData, schools[, c(1, 3)], by.x="Subject", by.y=1) ################################################### classData$Year <- 2000 + (classData$Term - 1000) %/% 10 ################################################### pastPapers <- subset(classData, !Current) ################################################### nPaper <- table(pastPapers$NewID) ################################################### library(lattice) dev.new() densityplot(as.numeric(nPaper), lwd=3) ################################################### uniYear <- 2009 - tapply(pastPapers$Year, list(pastPapers$NewID), min) + 1 ################################################### dev.new() hist(uniYear, breaks=seq(0.5, 9.5), axes=FALSE, col="grey") axis(2) mtext(1:9, at=1:9, side=1, font=2) ################################################### dev.new() jitYear <- jitter(uniYear) plot(jitYear, nPaper, type="n") abline(v=2:9, col="grey") points(jitYear, nPaper, pch=16, cex=2, col=rgb(0, 0, 1, .5)) ################################################### dev.new() tab <- table(pastPapers$SubjectName) ord <- order(tab) par(las=2, mar=c(6, 3, 0.5, 0.5)) barplot(tab[ord]) ################################################### pastPapers$Dept <- pastPapers$SubjectName pastPapers$Dept[!(pastPapers$Dept %in% c("STATS", "MATHS", "COMPSCI", "ECON"))] <- "OTHER" ################################################### nSubj <- do.call("rbind", tapply(factor(pastPapers$Dept), list(ID=pastPapers$NewID), table, simplify=FALSE)) # OR just table(pastPapers$NewID, pastPapers$Dept) ################################################### library(rggobi) ggobi(nSubj) ################################################### dev.new() stab <- table(pastPapers$School) sord <- order(stab) par(las=2, mar=c(10, 3, 0.5, 0.5)) barplot(stab[sord]) ################################################### pastPapers$Schl <- pastPapers$School pastPapers$Schl[!(pastPapers$School %in% c("Science", "Arts", "Business and Economics"))] <- "OTHER" ################################################### nSchool <- do.call("rbind", tapply(factor(pastPapers$Schl), list(ID=pastPapers$NewID), table, simplify=FALSE)) # OR just table(pastPapers$NewID, pastPapers$Schl) ################################################### ggobi(nSchool)