-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpollScore.R
More file actions
47 lines (37 loc) · 888 Bytes
/
pollScore.R
File metadata and controls
47 lines (37 loc) · 888 Bytes
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
library(dplyr)
needMax <- 0.9
weight <- (sum(1/qq))
print(weight)
print(nrow(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
))
})
sf <- data.frame(id=id, score=score)
sf <- (sf
%>% mutate(id = sub(",.*", "", id))
%>% group_by(id)
%>% summarise(score = sum(score))
)
ef <- read.table(input_files[[1]], header=TRUE)
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
score <- round(100*score)/100
})
## Check for suspicious overflows
print(df %>% filter(score>2))
scores <- (df
%>% filter(!is.na(score))
%>% transmute(macid=id, Polls_score=score)
)
summary(scores)
write.csv(file=csvname, df, row.names=FALSE)
# rdsave(scores)