-
Notifications
You must be signed in to change notification settings - Fork 1
/
exercise_solutions.Rmd
91 lines (69 loc) · 2.75 KB
/
exercise_solutions.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
---
title: "Exercise Solutions"
output:
html_document:
toc: false
---
```{r, include=FALSE}
library(knitr)
library(stringr)
knitr::opts_chunk$set(message=FALSE, warning=FALSE, eval=TRUE, echo=FALSE)
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(stringr))
source('reveal.R')
```
\
Follow the links below for solutions to each of the exercises you have completed on this course. Click on the 'code' buttons to reveal the R code associated with each question. If you would prefer these solutions as R scripts for later offline use then you can [find these here](course_code.html).
\
```{r, reveal, echo=FALSE, eval = isFALSE(show_text12)}
cat("solutions will be released as the course progresses")
```
```{r sol12, results='asis', eval = isTRUE(show_text12)}
file_name <- list.files('.') %>%
sort %>%
grep("(exercise_[12]_solution.html)", . , value=TRUE)
link_name <- file_name %>%
gsub("\\.html", "", .) %>%
paste0(., "s") %>%
gsub("_", " ", .) %>%
str_to_sentence(.)
paste0("- [", link_name, "](", file_name, "){target='_blank'}") %>%
cat(sep="\n\n")
```
```{r sol34, results='asis', eval = isTRUE(show_text34)}
file_name <- list.files('.') %>%
sort %>%
grep("(exercise_[34]_solution.html|exercise_[34]_ggplot_solution.html)", . , value=TRUE) %>%
.[c(1,3,2)]
link_name <- file_name %>%
gsub("\\.html", "", .) %>%
paste0(., "s") %>%
gsub("_", " ", .) %>%
str_to_sentence(.)
paste0("- [", link_name, "](", file_name, "){target='_blank'}") %>%
cat(sep="\n\n")
```
```{r sol56, results='asis', eval = isTRUE(show_text56)}
file_name <- list.files('.') %>%
sort %>%
grep("(exercise_[56]_solution.html)", . , value=TRUE)
link_name <- file_name %>%
gsub("\\.html", "", .) %>%
paste0(., "s") %>%
gsub("_", " ", .) %>%
str_to_sentence(.)
paste0("- [", link_name, "](", file_name, "){target='_blank'}") %>%
cat(sep="\n\n")
```
\
[Offline R scripts](course_code.html)
```{r, include = FALSE}
# TODO: generate list automagically
knitr::purl('./exercise_1_solution.Rmd', output = './exercise_solutions/exercise_1_solution.R', quiet = TRUE)
knitr::purl('./exercise_2_solution.Rmd', output = './exercise_solutions/exercise_2_solution.R', quiet = TRUE)
knitr::purl('./exercise_3_solution.Rmd', output = './exercise_solutions/exercise_3_solution.R', quiet = TRUE)
knitr::purl('./exercise_4_solution.Rmd', output = './exercise_solutions/exercise_4_solution.R', quiet = TRUE)
knitr::purl('./exercise_4_ggplot_solution.Rmd', output = './exercise_solutions/exercise_4_ggplot_solution.R', quiet = TRUE)
knitr::purl('./exercise_5_solution.Rmd', output = './exercise_solutions/exercise_5_solution.R', quiet = TRUE)
knitr::purl('./exercise_6_solution.Rmd', output = './exercise_solutions/exercise_6_solution.R', quiet = TRUE)
```