-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmidMerge.R
More file actions
46 lines (38 loc) · 1.19 KB
/
midMerge.R
File metadata and controls
46 lines (38 loc) · 1.19 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
library(readr)
library(dplyr)
## Pull midterm number from target name
num <- gsub("[[:alpha:].]", "", rtargetname)
## Use right_join to drop students dropped from TAmarks
## Need to track students who didn't write, and confirm MSAF NAs
scores <- (scores
%>% mutate (idnum = as.numeric(idnum))
%>% right_join(sa
%>% setNames(sub(num, "_curr", names(.)))
%>% transmute(idnum=as.numeric(idnum), sa=sa_curr, manVer=manVer_curr)
)
%>% mutate(version = ifelse(version==-1, NA, version)
, version = ifelse(is.na(version), manVer, version)
)
)
head(scores)
summary(scores)
## This code is cumbersome, but I'm trying to remember to use NAs
## in a principled fashion
## Old comment, still relevant?
## Need to check bestVer again, because we've supplemented
mismatch <- filter(scores,
(!is.na(manVer) && manVer != version)
|| (!is.na(version) && bestVer != version)
|| (!is.na(verScore)) && (verScore>0) && (verScore != bestScore)
)
print(mismatch)
## stopifnot(nrow(mismatch)==0)
print(filter(scores, is.na(bestScore)))
print(filter(scores, is.na(sa)))
scores <- (scores
%>% mutate(
bestScore = ifelse((is.na(bestScore) & sa==0), 0, bestScore)
, bestScore = bestScore+sa
)
)
print(summary(scores))