-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpollScore.R
59 lines (46 loc) · 1.02 KB
/
pollScore.R
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
52
53
54
55
56
57
58
59
library(dplyr)
library(shellpipes)
loadEnvironments()
needMax <- 0.9
weight <- (sum(1/qq))
print(weight)
print(dim(as.matrix(report)))
print(length(qq))
score <- apply(as.matrix(report), 1, function(s){
return(sum(
(nchar(as.character(s))>1)/qq
, na.rm=TRUE
))
})
scoref <- data.frame(id=id, score=score)
(scoref
%>% filter(grepl("UNKNOWN", id))
%>% mutate(score=score/(needMax*weight))
) %>% csvSave
sf <- (scoref
%>% mutate(id = sub(",.*", "", id))
%>% group_by(id)
%>% summarise(score = sum(score))
)
summary(sf)
ef <- tableRead()
summary(ef)
df <- full_join(sf, ef)
df <- within(df, {
extra[is.na(extra)] <- 0
score[is.na(score)] <- 0
manual[is.na(manual)] <- 0
score <- score+extra
score <- 2*pmin(1, score/(needMax*weight)+manual/2)
score <- round(100*score)/100
})
## What's up with manual
print(df %>% filter(manual>0))
## Check for suspicious overflows
print(df %>% filter(score>2))
scores <- (df
%>% filter(!is.na(score))
%>% transmute(Username=id, Polls_score=score)
)
summary(scores)
rdsSave(scores)