Note that generating .PDFs (as well as latex) may require you to install latex onto your machine.
How would I find out how to do this. I almost always start with googling stackoverflow for my R questions.
R.Version()
## $platform
## [1] "x86_64-w64-mingw32"
##
## $arch
## [1] "x86_64"
##
## $os
## [1] "mingw32"
##
## $system
## [1] "x86_64, mingw32"
##
## $status
## [1] ""
##
## $major
## [1] "3"
##
## $minor
## [1] "6.0"
##
## $year
## [1] "2019"
##
## $month
## [1] "04"
##
## $day
## [1] "26"
##
## $`svn rev`
## [1] "76424"
##
## $language
## [1] "R"
##
## $version.string
## [1] "R version 3.6.0 (2019-04-26)"
##
## $nickname
## [1] "Planting of a Tree"
R packages may contain code, data, or both. Many packages also include (sometimes extremely) helpful vignettes.
ctrl-alt-i or code-insert-chunk are two ways to add code block
data(package = 'ggplot2')
vignette(package = 'ggplot2')
vignette(package = 'ggplot2', "extending-ggplot2")
## starting httpd help server ... done
\[\bar{X}=\frac{1}{n}\sum_{i=1}^nX_i\]
You can also create inline latex with single dollar signs like this \(\bar{X}=\frac{1}{n}\sum_{i=1}^nX_i\). Nice!
Remember that you may need to install latex (one time) on your Mac or PC.
Take a look at chapters 21 and chapters 23 in R for Data Science.
https://www.rstudio.com has a lot of in-depth videos and cheat sheets. See also CheatSheets sub-menu under the RStudio help menu.
R Markdown Cheatsheets
Note that with GitHub, sometimes you need to work with the raw version of the file for it to render correctly!