-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmarks.R
More file actions
48 lines (38 loc) · 1 KB
/
marks.R
File metadata and controls
48 lines (38 loc) · 1 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
library(dplyr)
library(stringr)
library(shellpipes)
class <- (csvRead()
|> mutate(Username=sub("#", "", Username))
|> rename_with(~ sub(" ", "", .x))
|> rename_with(~ sub(" .*", "", .x))
)
names(class)
class <- (class
|> mutate(across(matches("^Assignment"), ~ if_else(is.na(.x), 0, .x)))
)
## summary(class)
## quit()
marks <- (tsvRead()
|> right_join(class)
|> mutate(idnum = as.character(idnum))
|> mutate(OrgDefinedId=sub("#", "", OrgDefinedId))
)
stopifnot(identical(marks$idnum, marks$OrgDefinedId))
marks <- marks |> select(-c(OrgDefinedId, `End-of-LineIndicator`))
apairs <- tibble(
assignment = names(marks) |> str_subset("^Assignment")
, notes = str_replace(assignment, "Assignment", "A") |> str_c("Notes")
)
for (i in seq_len(nrow(apairs))) {
marks <- (marks
|> mutate(
across(
all_of(apairs$assignment[i])
, ~ if_else(is.na(marks[[apairs$notes[i]]]), NA, .x)
)
)
)
}
marks <- marks |> select(-apairs$notes)
summary(marks %>% mutate_if(is.character, as.factor))
rdsSave(marks)