-
Notifications
You must be signed in to change notification settings - Fork 10
/
home_schedule.Rmd
116 lines (103 loc) · 4.63 KB
/
home_schedule.Rmd
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
---
title: "Schedule"
output:
bookdown::html_document2:
highlight: textmate
toc: false
toc_float:
collapsed: true
smooth_scroll: true
print: false
toc_depth: 4
number_sections: false
df_print: default
code_folding: none
self_contained: false
keep_md: false
encoding: 'UTF-8'
css: "assets/lab.css"
include:
after_body: assets/footer-lab.html
---
```{r,child="assets/header-lab.Rmd"}
```
```{r,eval=TRUE,include=FALSE}
library(lubridate)
library(dplyr)
library(kableExtra)
library(formattable)
library(yaml)
```
```{r,eval=TRUE,include=FALSE}
s <- read.csv("schedule.csv",sep=";",stringsAsFactors=F,header=T,na.strings="",colClasses="character")
# remove rows that are completely NA
s <- s[!apply(s,1,function(x) all(is.na(x))),]
s <- s %>%
# missing values in date and room are filled
tidyr::fill(date,room,link_room,.direction="down") %>%
# convert date characters to date objects
dplyr::mutate(date=format(as_datetime(date,format="%d/%m/%Y"),"%d-%b-%Y")) %>%
dplyr::mutate(day=format(as_datetime(date,format="%d-%b-%Y"),"%a")) %>%
dplyr::group_by(date) %>%
dplyr::mutate(start_time=format(as_datetime(start_time,format="%H:%M"),"%H:%M"),
end_time=format(as_datetime(end_time,format="%H:%M"),"%H:%M")) %>%
as.data.frame() %>%
dplyr::mutate(room=ifelse(is.na(link_room),room,paste0("<a href='",link_room,"'>",room,"</a>"))) %>%
# create day label (with date, day, room)
dplyr::mutate(date=paste0("<p style='font-size:110%;padding-top:10px;padding-bottom:5px;margin-top:10px;'><span style='font-weight:bold;'><span style='color:",color_primary,";'><i class='fas fa-calendar' style='margin-left:5px;margin-right:5px;'></i></span>",date,"</span>",
"<span style='color:white;border-radius:4px;padding-right:4px;padding-left:4px;background:",color_primary,";margin-left:9px;margin-right:7px;'>",day,"</span>",
"<span style='color:",color_primary,";'><i class='fas fa-map-marker-alt' style='margin-left:5px;margin-right:5px;'></i></span>",room,"</p>")) %>%
# style topic
dplyr::mutate(topic=ifelse(tolower(topic)=="coffee break" | tolower(topic)=="lunch",paste0("<span style='color:white;font-weight:bold;border-radius:4px;padding:4px;background:#BDBDBD;'>",topic,"</span>"),paste0("<span style='margin-right:5px;'>",topic,"</span>"))) %>%
# add links to topic
dplyr::mutate(topic=ifelse(is.na(link_slide),topic,paste0("<span>",topic,"<a href='",link_slide,"'><i class='fas fa-file-powerpoint' style='margin-left:4px;margin-right:4px;'></i></a></span>"))) %>%
mutate(topic=ifelse(is.na(link_lab),topic,paste0("<span>",topic,"<a href='",link_lab,"'><i class='fas fa-file-alt' style='margin-left:4px;margin-right:4px;'></i></a></span>"))) %>%
dplyr::mutate(time=paste0(start_time," - ",end_time)) %>%
dplyr::mutate(teacher=ifelse(is.na(teacher),"",teacher)) %>%
dplyr::mutate(assistant=ifelse(is.na(assistant),"",assistant)) %>%
dplyr::select(date,room,time,topic,teacher,assistant)
if(all(is.na(s$assistant)) | all(s$assistant=="")) s$assistant <- NULL
```
<div class="table-schedule">
```{r,eval=TRUE,echo=FALSE,chunk.title=NULL}
# grouping vector
r <- rle(s$date)$length
names(r) <- rle(s$date)$values
cnames <- c("Time","Topic","Teacher","Assistant")
s %>%
dplyr::select(-date,-room) %>%
setNames(cnames[1:ncol(.)]) %>%
kable(format="html",escape=FALSE) %>%
kable_styling(bootstrap_options=c("hover","condensed"),position="center",full_width=TRUE) %>%
column_spec(1,width="7em") %>%
column_spec(2,width="16em") %>%
pack_rows(index=r,label_row_css="background:white;",escape=F,indent=FALSE)
```
<!-- marker legend -->
<p class="small" style="margin-top:20px;">
<span>
<span style="margin-left:6px; margin-right:6px;">
<i class="fas fa-calendar" style="margin-left:4px; margin-right:4px;"></i> Date
</span>
<span style="margin-left:6px; margin-right:6px;">
<i class="fas fa-map-marker-alt" style="margin-left:4px; margin-right:4px;"></i> Venue
</span>
<span style="margin-left:6px; margin-right:6px;">
<i class="fas fa-file-powerpoint" style="margin-left:4px; margin-right:4px;"></i> Slides
</span>
<span style="margin-left:6px; margin-right:6px;">
<i class="fas fa-file-alt" style="margin-left:4px; margin-right:4px;"></i> Exercises
</span>
</span>
</p>
```{r,echo=FALSE,results='asis'}
# add assistant list if present
asst <- yaml::read_yaml("_site.yml")$assistant
if(!is.null(asst)) {
cat('<p class="small" style="margin-top:20px;">',
'<span style="margin-left:4px; margin-right:4px;"><i class="fas fa-users" style="margin-left:4px; margin-right:4px;"></i></span>',
paste(asst,collapse=", "),
'</p>')
}
```
</div>