-
Notifications
You must be signed in to change notification settings - Fork 1
/
lectures.Rmd
165 lines (126 loc) · 5.34 KB
/
lectures.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
---
title: "Lectures"
---
```{r include = FALSE}
library(tidyverse)
library(stringr)
library(httr)
```
```{r include = FALSE}
# Import schedule
rawdat <- read.csv(file.path("course-admin", "schedule_2024.csv"), stringsAsFactors = FALSE, colClasses = list(course = 'factor', dow = 'factor'))
rawdat$course <- as.factor(rawdat$course)
# Class meetings
rawdat_cm <- rawdat[rawdat$course == "STAT540",]
cdat <- rawdat_cm %>%
mutate(ugly_date = ISOdate(2024, match(month, month.name), day),
date = sprintf("%s %s %s",
dow, months(ugly_date, abbreviate = TRUE),
day),
notes = ifelse(grepl("^lect", lect) & raw_notes != "",
sprintf("%s: %s", lect, raw_notes), raw_notes))
## link to the class page of any class meetings where such exists
req <- GET("https://api.github.com/repos/STAT540-UBC/lectures/git/trees/main?recursive=1")
stop_for_status(req)
filelist <- unlist(lapply(content(req)$tree, "[", "path"), use.names = F)
# now grab pdf & html file names
cmdat <-
data.frame(file = filelist[grepl('^lect.*pdf|^lect.*html', basename(filelist))],
stringsAsFactors = FALSE) %>%
mutate(lect = str_extract(file, "lect[0-9]+")) %>%
mutate(lect = sapply(lect, str_replace, pattern="lect0*([0-9]+)",
replacement="lecture-\\1")) %>%
mutate(type = ifelse(grepl("pdf", file), "pdf", "html")) %>%
pivot_wider(id_cols = lect, names_from = type, values_from = file)
if (nrow(cmdat) >0){
cdat <- cdat %>% left_join(cmdat, by="lect")
}else{
cdat$file <- NA
}
pdf_exists <- grepl("*.pdf", cdat$pdf)
html_exists <- grepl("*.html", cdat$html)
if (length(html_exists) == 0){
if (length(pdf_exists) > 0){
html_exists <- rep(FALSE, length(pdf_exists))
}
}
if (length(pdf_exists) == 0){
if (length(html_exists) > 0){
pdf_exists <- rep(FALSE, length(html_exists))
}
}
# Insert placeholder link to notes
#cdat$notes[pdf_exists] <-
# str_replace(cdat$notes[which(pdf_exists)],
# "(lecture-[0-9]+)|(lecture-[1-9]+)", '<a href="LINK">\\1</a>')
cdat$notes <- gsub("lecture-", "Lecture ", cdat$notes)
cdat$notes[pdf_exists|html_exists] <-
str_replace(cdat$notes[which(pdf_exists|html_exists)],
"(Lecture [0-9]+)|(Lecture [1-9]+)", '[\\1](LINK)')
for (i in seq_along(html_exists)){
if (html_exists[i]){
# Replace placeholder "LINK" with html file names
cdat$notes[i] <- str_replace(cdat$notes[i], "LINK",
paste0("https://stat540-ubc.github.io/lectures/",
cdat$html[i]))
if (pdf_exists[i]){
# Append pdf files
cdat$notes[i] <- paste0(cdat$notes[i],
paste0("\ [(pdf)](https://github.com/STAT540-UBC/lectures/raw/main/",
cdat$pdf[i], ")"))
}
}else if (pdf_exists[i]){
# Replace placeholder "LINK" with pdf file names
cdat$notes[i] <- str_replace(cdat$notes[i], "LINK",
paste0("https://github.com/STAT540-UBC/lectures/raw/main/",
cdat$pdf[i]))
}}
dat_cm <- cdat %>% split(cdat$course)
dat_cm <- lapply(dat_cm, 'rownames<-', NULL)
```
### Class meetings and schedule
**Time** : Tues Thurs 9:00 - 10:30am
**Location**: Building and room number listed on Canvas
```{r results = 'asis', echo = FALSE}
# add readings
sched <- dat_cm[["STAT540"]] %>%
mutate(readings = "") %>%
select(date, readings, notes, instructor)
# lect 1
sched$readings[1] <- "[1](https://stat540-ubc.github.io/syllabus.html)"
# lect 3
sched$readings[3] <- "[1](https://github.com/STAT540-UBC/lectures/blob/main/lect03-eda/README.md)"
# lect 4
sched$readings[4] <- "
[1](http://genomicsclass.github.io/book/pages/populations_and_samples.html),
[2](http://genomicsclass.github.io/book/pages/random_variables.html),
[3](http://genomicsclass.github.io/book/pages/clt_and_t-distribution.html)
"
# lect 5
sched$readings[5] <- "[1](https://github.com/STAT540-UBC/lectures/blob/main/lect05-twoGroup/README.md)"
# lect 6
sched$readings[6] <- "
[1](http://genomicsclass.github.io/book/pages/matrix_notation.html),
[2](http://genomicsclass.github.io/book/pages/matrix_operations.html),
[3](http://genomicsclass.github.io/book/pages/expressing_design_formula.html)
"
# lect 7
sched$readings[8] <- "[1](http://genomicsclass.github.io/book/pages/interactions_and_contrasts.html)"
# lect 8
sched$readings[9] <- "[1](https://github.com/STAT540-UBC/lectures/blob/main/lect08-continuous/README.md)"
# lect 9
sched$readings[10] <- "[1](https://github.com/STAT540-UBC/lectures/blob/main/lect09-multipleTesting/README.md)"
# lect 10
sched$readings[11] <- "[1](https://github.com/STAT540-UBC/lectures/blob/main/lect10-RNAseq/README.md)"
# lect 12
sched$readings[15] <- "[1](https://github.com/STAT540-UBC/lectures/blob/main/lect12-gsea/README.md)"
# print final table
knitr::kable(sched %>%
dplyr::rename(Date=date, "Pre-reading"=readings, Topic=notes, Instructor=instructor),
"html", escape = FALSE) %>%
kableExtra::column_spec(1, width = "6em") %>%
kableExtra::kable_styling(full_width = TRUE)
```
**Supplemental Files**:
* Additional companion notes can be found in the [STAT540-UBC/resources GitHub repo](https://github.com/STAT540-UBC/resources)
* Source files for lectures can be found the [STAT540-UBC/lectures GitHub repo](https://github.com/STAT540-UBC/lectures)