generated from jhudsl/OTTR_Template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
02-chapter_of_course.Rmd
261 lines (148 loc) · 6.67 KB
/
02-chapter_of_course.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# A new chapter
If you haven't yet read the getting started Wiki pages; [start there](https://www.ottrproject.org/getting_started.html).
To see the rendered version of this chapter and the rest of the template, see here: https://jhudatascience.org/OTTR_Template/.
Every chapter needs to start out with this chunk of code:
```{r, include = FALSE}
ottrpal::set_knitr_image_path()
```
## Learning Objectives
Every chapter also needs Learning objectives that will look like this:
This chapter will cover:
- {You can use https://tips.uark.edu/using-blooms-taxonomy/ to define some learning objectives here}
- {Another learning objective}
## Libraries
For this chapter, we'll need the following packages attached:
*Remember to add [any additional packages you need to your course's own docker image](https://github.com/jhudsl/OTTR_Template/wiki/Using-Docker#starting-a-new-docker-image).
```{r}
library(magrittr)
```
## Topic of Section
You can write all your text in sections like this, using `##` to indicate a new header. you can use additional pound symbols to create lower levels of headers.
See [here](https://www.rstudio.com/wp-content/uploads/2015/02/rmarkdown-cheatsheet.pdf) for additional general information about how you can format text within R Markdown files. In addition, see [here](https://pandoc.org/MANUAL.html#pandocs-markdown) for more in depth and advanced options.
### Subtopic
Here's a subheading (using three pound symbols) and some text in this subsection!
## Code examples
You can demonstrate code like this:
```{r}
output_dir <- file.path("resources", "code_output")
if (!dir.exists(output_dir)) {
dir.create(output_dir)
}
```
And make plots too:
```{r}
hist_plot <- hist(iris$Sepal.Length)
```
You can also save these plots to file:
```{r}
png(file.path(output_dir, "test_plot.png"))
hist_plot
dev.off()
```
## Image example
How to include a Google slide. It's simplest to use the `ottrpal` package:
```{r, fig.align='center', out.width="100%", echo = FALSE, fig.alt= "Major point!! example image"}
ottrpal::include_slide("https://docs.google.com/presentation/d/1YmwKdIy9BeQ3EShgZhvtb3MgR8P6iDX4DfFD65W_gdQ/edit#slide=id.gcc4fbee202_0_141")
```
But if you have the slide or some other image locally downloaded you can also use HTML like this:
<img src="resources/images/02-chapter_of_course_files/figure-html//1YmwKdIy9BeQ3EShgZhvtb3MgR8P6iDX4DfFD65W_gdQ_gcc4fbee202_0_141.png" title="Major point!! example image" alt="Major point!! example image" style="display: block; margin: auto;" />
## Video examples
You may also want to embed videos in your course. If alternatively, you just want to include a link you can do so like this:
Check out this [link to a video](https://www.youtube.com/embed/VOCYL-FNbr0) using markdown syntax.
### Using `knitr`
To embed videos in your course, you can use `knitr::include_url()` like this:
Note that you should use `echo=FALSE` in the code chunk because we don't want the code part of this to show up. If you are unfamiliar with [how R Markdown code chunks work, read this](https://rmarkdown.rstudio.com/lesson-3.html).
```{r, echo=FALSE}
knitr::include_url("https://www.youtube.com/embed/VOCYL-FNbr0")
```
### Using HTML
<iframe src="https://www.youtube.com/embed/VOCYL-FNbr0" width="672" height="400px"></iframe>
### Using `knitr`
```{r, fig.align="center", echo=FALSE, out.width="100%"}
knitr::include_url("https://drive.google.com/file/d/1mm72K4V7fqpgAfWkr6b7HTZrc3f-T6AV/preview")
```
### Using HTML
<iframe src="https://drive.google.com/file/d/1mm72K4V7fqpgAfWkr6b7HTZrc3f-T6AV/preview" width="672" height="800px"></iframe>
## Website Examples
Yet again you can use a link to a website like so:
[A Website](https://yihui.org)
You might want to have users open a website in a new tab by default, especially if they need to reference both the course and a resource at once.
[A Website](https://yihui.org){target="_blank"}
Or, you can embed some websites.
### Using `knitr`
This works:
```{r, fig.align="center", echo=FALSE}
knitr::include_url("https://yihui.org")
```
### Using HTML
<iframe src="https://yihui.org" width="672" height="400px"></iframe>
If you'd like the URL to show up in a new tab you can do this:
```
<a href="https://www.linkedin.com" target="_blank">LinkedIn</a>
```
## Citation examples
We can put citations at the end of a sentence like this [@rmarkdown2021].
Or multiple citations [@rmarkdown2021, @Xie2018].
but they need a ; separator [@rmarkdown2021; @Xie2018].
In text, we can put citations like this @rmarkdown2021.
## Stylized boxes
Occasionally, you might find it useful to emphasize a particular piece of information. To help you do so, we have provided css code and images (no need for you to worry about that!) to create the following stylized boxes.
You can use these boxes in your course with either of two options: using HTML code or Pandoc syntax.
### Using `rmarkdown` container syntax
The `rmarkdown` package allows for a different syntax to be converted to the HTML that you just saw and also allows for conversion to LaTeX. See the [Bookdown](https://bookdown.org/yihui/rmarkdown-cookbook/custom-blocks.html) documentation for more information [@Xie2020]. Note that Bookdown uses Pandoc.
```
::: {.notice}
Note using rmarkdown syntax.
:::
```
::: {.notice}
Note using rmarkdown syntax.
:::
As an example you might do something like this:
::: {.notice}
Please click on the subsection headers in the left hand
navigation bar (e.g., 2.1, 4.3) a second time to expand the
table of contents and enable the `scroll_highlight` feature
([see more](introduction.html#scroll-highlight))
:::
### Using HTML
To add a warning box like the following use:
```
<div class = "notice">
Followed by the text you want inside
</div>
```
This will create the following:
<div class = "notice">
Followed by the text you want inside
</div>
Here is a `<div class = "warning">` box:
<div class = "warning">
Note text
</div>
Here is a `<div class = "github">` box:
<div class = "github">
GitHub text
</div>
Here is a `<div class = "dictionary">` box:
<div class = "dictionary">
dictionary text
</div>
Here is a `<div class = "reflection">` box:
<div class = "reflection">
reflection text
</div>
Here is a `<div class = "wip">` box:
<div class = "wip">
Work in Progress text
</div>
## Dropdown summaries
<details><summary> You can hide additional information in a dropdown menu </summary>
Here's more words that are hidden.
</details>
## Print out session info
You should print out session info when you have code for [reproducibility purposes](https://jhudatascience.org/Reproducibility_in_Cancer_Informatics/managing-package-versions.html).
```{r}
devtools::session_info()
```
[many links]: https://github.com/jhudsl/OTTR_Template