generated from allisonhorst/meds-distill-template
-
Notifications
You must be signed in to change notification settings - Fork 23
/
functions.R
49 lines (45 loc) · 1.51 KB
/
functions.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
librarian::shelf(
dplyr, DT, readr, tidyr)
options(readr.show_col_types = F)
# edit: [EDS 211 Team Science - Google Sheets](https://docs.google.com/spreadsheets/d/1hQGPNBotVV2KfouaQE8U2tSTZBuIuflsMtvVWQwKcx8/edit#gid=0)
sched_csv <- "https://docs.google.com/spreadsheets/d/e/2PACX-1vSbjLIAlor277KKU5tUys5Rb290KmO8SGMquPXErF9ELPifCJhbFYNKOVvQIv6OR7iQT9OKXoO4zgQw/pub?gid=0&single=true&output=csv"
get_sched <- function(){
d_sched <- readr::read_csv(sched_csv) %>%
tidyr::fill(Module)
}
dt_sched <- function(d_sched){
i_mod <- which(names(d_sched) == "Module") - 1
d_sched %>%
mutate(
Lecture = ifelse(
is.na(Lecture),
"",
ifelse(
is.na(Lecture_link),
Lecture,
glue::glue("<a href='{Lecture_link}' target='_blank'>{Lecture}</a>"))),
Lab = ifelse(
is.na(Lab),
"",
ifelse(
is.na(Lab_link),
Lab,
glue::glue("<a href='{Lab_link}' target='_blank'>{Lab}</a>"))),
Reading = ifelse(
is.na(Reading),
"",
ifelse(
is.na(Reading_link),
Reading,
glue::glue("<a href='{Reading_link}' target='_blank'>{Reading}</a>")))) %>%
select(-Lecture_link, -Lab_link, -Reading_link, -`Lab\nTechnology`) %>%
DT::datatable(
rownames = F,
extensions = 'RowGroup',
options = list(
dom = 't',
rowGroup = list(
dataSrc=c(i_mod)),
columnDefs = list(list(visible=F, targets=c(i_mod)))),
escape = F)
}