forked from datacarpentry/R-ecology-lesson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.R
60 lines (51 loc) · 1.99 KB
/
setup.R
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
## file structure
if (! file.exists("data")) dir.create("data")
if (!file.exists("data/surveys.csv")) {
download.file("https://ndownloader.figshare.com/files/2292172",
"data/surveys.csv")
}
if (!file.exists("data/species.csv")) {
download.file("https://ndownloader.figshare.com/files/3299483",
"data/species.csv")
}
if (!file.exists("data/plots.csv")) {
download.file("https://ndownloader.figshare.com/files/3299474",
"data/plots.csv")
}
if (!file.exists("data/portal_data_joined.csv")) {
download.file("https://ndownloader.figshare.com/files/2292169",
"data/portal_data_joined.csv")
}
if (!file.exists("data/portal_mammals.sqlite")) {
download.file("https://ndownloader.figshare.com/files/2292171",
"data/portal_mammals.sqlite")
}
## knitr options
library(knitr)
library(methods)
suppressPackageStartupMessages(library(tidyverse))
knitr::opts_chunk$set(results='hide', fig.path='img/R-ecology-',
comment = "#>", purl = FALSE, fig.keep='last')
### Custom hooks
## hook for challenges answers
knitr::knit_hooks$set(answer = function(before, options, envir) {
if (before) {
paste(
"<div class=\"accordion\">",
"<h3 class=\"toc-ignore\">Answer</h3>",
"<div style=\"background: #fff;\">", sep = "\n")
} else {
paste("</div>", "</div>", sep = "\n")
}
})
eng_text_answer <- knitr:::eng_html_asset(
paste(
"<div class=\"accordion\">",
"<h3 class=\"toc-ignore\">Answer</h3>",
"<div style=\"background: #fff;\">",
"<p>", sep = "\n"),
paste(
"</div>", "</div>", "</p>", sep = "\n"
)
)
knitr::knit_engines$set(text_answer = eng_text_answer)