-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnewscores.R
More file actions
51 lines (39 loc) · 1.25 KB
/
newscores.R
File metadata and controls
51 lines (39 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
sheets <- read.csv(input_files[[1]], header=FALSE, row.names=1)
versionOrder <- read.table(input_files[[2]], header=FALSE, row.names=1)
key <- as.character(read.table(input_files[[3]], header=FALSE, row.names=1)[[1]])
answers <- as.matrix(sheets[-1])
allScores <- apply(answers, 1, function(a){
vs <- sapply(versionOrder, function(v){
return(sum(a[order(v)]==key))
})
return((vs))
})
bestScore <- apply(allScores, 2, max)
bestVer <- apply(allScores, 2, which.max)
scoreVersion <- data.frame(
idnum = as.numeric(as.character(rownames(sheets))),
bubble=sheets[[1]],
bestVer, bestScore
)
print(subset(scoreVersion, bubble<1))
# Temporarily patch missing version
scoreVersion <- within(scoreVersion, {
bubble[bubble<1] <- 1
})
# Merge TA version numbers
allVersion <- merge(scoreVersion, ta)
vprob <- subset(allVersion,
(bubble != bestVer) | (bubble != paperVersion)
)
print(vprob)
# print(allScores[ , rownames(vprob)])
bubbleSel <- sapply(1:nrow(sheets), function(n){
return(allScores[[scoreVersion$bubble[[n]], n]])
return(c(scoreVersion$bubble[[n]], n))
})
bubbleScores <- data.frame(
idnum = as.numeric(as.character(rownames(sheets))),
score = bubbleSel
)
write.csv(bubbleScores, csvname)
# rdsave(key, answers, versionOrder, scoreVersion, bubbleScores)