/
README.Rmd
88 lines (73 loc) · 2.57 KB
/
README.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
---
output:
html_document:
keep_md: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
```{r include=FALSE}
library(rvest)
library(dplyr)
library(purrr)
```
```{r}
main_url <- "http://swcarpentry.github.io/r-novice-gapminder/"
```
```{r}
get_time <- function(href, return_value="sum"){
child_url <- paste0(main_url, href)
times <-
read_html(child_url) %>%
html_nodes("body blockquote.objectives div.col-md-3") %>%
html_text() %>%
strsplit("\n") %>%
unlist() %>%
{grep("min", ., value=TRUE)}
if (length(times) == 0) return(0)
times <-
sub(".*(\\d{2}) min.*$", "\\1", times) %>%
{suppressWarnings(as.integer(.))} %>%
{replace(., is.na(.),0)}
if (return_value == "teaching") {
times[1]
} else if (return_value == "exercise") {
times[2]
} else {
sum(times)
}
}
```
I’ll be teaching an R workshop based on the [R for Reproducible Scientific Analysis](`r main_url`) Software Carpentry lesson plan (lessons 1-10). The total estimated teaching and exercise time is more than 7 hrs (which is more than the allocated time) and so the purpose of this repo is to contain summary notes.
```{r}
syllabus <-
read_html(main_url) %>%
html_nodes("body div.syllabus table td.col-md-3 a") %>%
html_attr("href") %>%
{data.frame(href = ., stringsAsFactors=FALSE)} %>%
mutate(
lesson_plan = ifelse(grepl("\\d{2}", href),
sub(".*(\\d{2}).*", "\\1", href),
0) %>% as.integer(),
time_teaching = map(href, get_time, return_value="teaching") %>% unlist(),
time_exercise = map(href, get_time, return_value="exercise") %>% unlist(),
time_total = map(href, get_time) %>% unlist()
)
# Time (hr) for lessons 1-10
syllabus %>%
filter(lesson_plan <= 10) %>%
select(starts_with("time")) %>%
colSums() /60
```
### Summary notes:
- [01: Introduction to R and RStudio](summary_notes/01-rstudio-intro.md)
- [02: Project Management With RStudio](summary_notes/02-project-intro.md)
- [03: Seeking Help](summary_notes/03-seeking-help.md)
- [04: Data Structures](summary_notes/04-data-structures-part1.md)
- [05: Exploring Data Frames](summary_notes/05-data-structures-part2.md)
- [06: Subsetting Data](summary_notes/06-data-subsetting.md)
- [07: Control Flow](summary_notes/07-control-flow.md)
- [08: Creating Publication-Quality Graphics](summary_notes/08-plot-ggplot2.md)
- [09: Vectorization](summary_notes/09-vectorization.md)
- [10: Functions Explained](summary_notes/10-functions.md)
A list of R commands (parsed from the lessons) is found in [r-commands.md](r-commands.md).