This repository has been archived by the owner on Jul 10, 2024. It is now read-only.
forked from datacarpentry/R-ecology-lesson
-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
setup.R
60 lines (51 loc) · 1.98 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_raw")) dir.create("data_raw")
if (!file.exists("data_raw/surveys.csv")) {
download.file("https://ndownloader.figshare.com/files/2292172",
"data_raw/surveys.csv")
}
if (!file.exists("data_raw/species.csv")) {
download.file("https://ndownloader.figshare.com/files/3299483",
"data_raw/species.csv")
}
if (!file.exists("data_raw/plots.csv")) {
download.file("https://ndownloader.figshare.com/files/3299474",
"data_raw/plots.csv")
}
if (!file.exists("data_raw/portal_data_joined.csv")) {
download.file("https://ndownloader.figshare.com/files/2292169",
"data_raw/portal_data_joined.csv")
}
if (!file.exists("data_raw/portal_mammals.sqlite")) {
download.file("https://ndownloader.figshare.com/files/2292171",
"data_raw/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)
### 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)