Chapter 3 Topic of Section
You can write all your text in sections like this!
3.1 Subtopic
Here’s a subheading and some text in this subsection!
3.1.1 Code examples
You can demonstrate code like this:
<- file.path("resources", "code_output")
output_dir if (!dir.exists(output_dir)) {
dir.create(output_dir)
}
And make plots too:
<- hist(iris$Sepal.Length) hist_plot
You can also save these plots to file:
png(file.path(output_dir, "test_plot.png"))
hist_plot
## $breaks
## [1] 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0
##
## $counts
## [1] 5 27 27 30 31 18 6 6
##
## $density
## [1] 0.06666667 0.36000000 0.36000000 0.40000000 0.41333333 0.24000000 0.08000000
## [8] 0.08000000
##
## $mids
## [1] 4.25 4.75 5.25 5.75 6.25 6.75 7.25 7.75
##
## $xname
## [1] "iris$Sepal.Length"
##
## $equidist
## [1] TRUE
##
## attr(,"class")
## [1] "histogram"
dev.off()
## png
## 2
3.1.2 Image example
How to include a Google slide. It’s simplest to use the ottrpal
package:
But if you have the slide or some other image locally downloaded you can also use html like this:
3.1.3 Video examples
To show videos in your course, you can use markdown syntax like this:
Alternatively, you can use knitr::include_url()
like this:
Note that we are using 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.
OR this works:
3.1.5 Links to websites
Examples of including a website link.
This works:
OR this:
OR this:
3.1.6 Citation examples
We can put citations at the end of a sentence like this (Allaire et al. 2021). Or multiple citations Xie, Allaire, and Grolemund (2018).
but they need a ; separator (Allaire et al. 2021; Xie, Allaire, and Grolemund 2018).
In text, we can put citations like this Allaire et al. (2021).
3.1.7 FYI boxes
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).
3.1.8 Dropdown summaries
You can hide additional information in a dropdown menu
Here’s more words that are hidden.3.2 Print out session info
You should print out session info when you have code for reproducibility purposes.
::session_info() devtools
## ─ Session info ───────────────────────────────────────────────────────────────
## setting value
## version R version 4.0.2 (2020-06-22)
## os Ubuntu 20.04.3 LTS
## system x86_64, linux-gnu
## ui X11
## language (EN)
## collate en_US.UTF-8
## ctype en_US.UTF-8
## tz Etc/UTC
## date 2022-10-06
##
## ─ Packages ───────────────────────────────────────────────────────────────────
## package * version date lib source
## assertthat 0.2.1 2019-03-21 [1] RSPM (R 4.0.3)
## bookdown 0.24 2022-02-15 [1] Github (rstudio/bookdown@88bc4ea)
## callr 3.4.4 2020-09-07 [1] RSPM (R 4.0.2)
## cli 2.0.2 2020-02-28 [1] RSPM (R 4.0.0)
## crayon 1.3.4 2017-09-16 [1] RSPM (R 4.0.0)
## curl 4.3 2019-12-02 [1] RSPM (R 4.0.3)
## desc 1.2.0 2018-05-01 [1] RSPM (R 4.0.3)
## devtools 2.3.2 2020-09-18 [1] RSPM (R 4.0.3)
## digest 0.6.25 2020-02-23 [1] RSPM (R 4.0.0)
## ellipsis 0.3.1 2020-05-15 [1] RSPM (R 4.0.3)
## evaluate 0.14 2019-05-28 [1] RSPM (R 4.0.3)
## fansi 0.4.1 2020-01-08 [1] RSPM (R 4.0.0)
## fs 1.5.0 2020-07-31 [1] RSPM (R 4.0.3)
## glue 1.6.1 2022-01-22 [1] CRAN (R 4.0.2)
## highr 0.8 2019-03-20 [1] RSPM (R 4.0.3)
## hms 0.5.3 2020-01-08 [1] RSPM (R 4.0.0)
## htmltools 0.5.0 2020-06-16 [1] RSPM (R 4.0.1)
## httr 1.4.2 2020-07-20 [1] RSPM (R 4.0.3)
## jquerylib 0.1.4 2021-04-26 [1] CRAN (R 4.0.2)
## knitr 1.33 2022-02-15 [1] Github (yihui/knitr@a1052d1)
## lifecycle 1.0.0 2021-02-15 [1] CRAN (R 4.0.2)
## magrittr * 2.0.2 2022-01-26 [1] CRAN (R 4.0.2)
## memoise 1.1.0 2017-04-21 [1] RSPM (R 4.0.0)
## ottrpal 0.1.2 2022-02-15 [1] Github (jhudsl/ottrpal@1018848)
## pillar 1.4.6 2020-07-10 [1] RSPM (R 4.0.2)
## pkgbuild 1.1.0 2020-07-13 [1] RSPM (R 4.0.2)
## pkgconfig 2.0.3 2019-09-22 [1] RSPM (R 4.0.3)
## pkgload 1.1.0 2020-05-29 [1] RSPM (R 4.0.3)
## png 0.1-7 2013-12-03 [1] CRAN (R 4.0.2)
## prettyunits 1.1.1 2020-01-24 [1] RSPM (R 4.0.3)
## processx 3.4.4 2020-09-03 [1] RSPM (R 4.0.2)
## ps 1.3.4 2020-08-11 [1] RSPM (R 4.0.2)
## purrr 0.3.4 2020-04-17 [1] RSPM (R 4.0.3)
## R6 2.4.1 2019-11-12 [1] RSPM (R 4.0.0)
## readr 1.4.0 2020-10-05 [1] RSPM (R 4.0.2)
## remotes 2.2.0 2020-07-21 [1] RSPM (R 4.0.3)
## rlang 0.4.10 2022-02-15 [1] Github (r-lib/rlang@f0c9be5)
## rmarkdown 2.10 2022-02-15 [1] Github (rstudio/rmarkdown@02d3c25)
## rprojroot 2.0.2 2020-11-15 [1] CRAN (R 4.0.2)
## sessioninfo 1.1.1 2018-11-05 [1] RSPM (R 4.0.3)
## stringi 1.5.3 2020-09-09 [1] RSPM (R 4.0.3)
## stringr 1.4.0 2019-02-10 [1] RSPM (R 4.0.3)
## testthat 3.0.1 2022-02-15 [1] Github (R-lib/testthat@e99155a)
## tibble 3.0.3 2020-07-10 [1] RSPM (R 4.0.2)
## usethis 2.1.5.9000 2022-02-15 [1] Github (r-lib/usethis@57b109a)
## vctrs 0.3.4 2020-08-29 [1] RSPM (R 4.0.2)
## withr 2.3.0 2020-09-22 [1] RSPM (R 4.0.2)
## xfun 0.26 2022-02-15 [1] Github (yihui/xfun@74c2a66)
## yaml 2.2.1 2020-02-01 [1] RSPM (R 4.0.3)
##
## [1] /usr/local/lib/R/site-library
## [2] /usr/local/lib/R/library