-
Notifications
You must be signed in to change notification settings - Fork 51
/
121_sources.Rmd
executable file
·50 lines (47 loc) · 1.32 KB
/
121_sources.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
<style>@import url(style.css);</style>
[Introduction to Data Analysis](index.html "Course index")
# Sources
Here's a selection of links cited in the course material. The list is not yet complete, so this page is not mentioned in the course listings.
```{r links, echo = FALSE, results='asis'}
##
## ida.links(): list all Markdown links in a list of pages
##
ida.links <- function(x = 0:12, detail = FALSE) {
x = ida.files(x)
# parse
links <- sapply(x, FUN = function(x) {
conn <- file(x)
text <- readLines(conn, warn = FALSE)
text <- text[grepl("(\\[[a-z-]+\\]): http(.*)", text)]
close(conn)
text
})
# format
if(!detail)
links <- unique(unlist(links))
return(links)
}
##
## ida.sources(): return Markdown links extracted from the course pages
##
ida.sources = function(x) {
x = lapply(x, FUN = function(x) {
l = ida.links(x)
# links with titles and bracket author
l = gsub("(\\[[a-z-]+\\]): http(.*) \"(.*)\\((.*)\\)\"", "[\\3](http\\2) (\\4)", l)
# links with titles
l = gsub("(\\[[a-z-]+\\]): http(.*) \"(.*)\"", "[\\3](http\\2)", l)
# links without titles
l = l[-which(grepl("(\\[[a-z-]+\\]): http(.*)", l))] ## "\\1(http\\2)"
# print
if(length(l) > 0) {
cat("\n\n## Session ", x, "\n")
cat(paste("*", l), sep = "\n")
}
})
}
##
## show all sessions
##
ida.sources(1:12)
```