2023-07-25

R Markdown

This is an R Markdown presentation. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.

Installation of R Markdown

Install from CRAN

  • install.packages(‘rmarkdown’)

R Markdown

  • The document format “R Markdown” was first introduced in the knitr package in early 2012.
  • The idea was to embed code chunks (of R or other languages) in Markdown documents.
  • In fact, knitr supported several authoring languages from the beginning in addition to Markdown, including LaTeX, HTML.

More about R Markdown Features

  • If you want to generate PDF output, you will need to install LaTeX. For R Markdown users who have not installed LaTeX before, we recommend that you install TinyTeX (https://yihui.name/tinytex/):

  • install.packages(‘tinytex’)

  • tinytex::install_tinytex() # install TinyTeX

How to read CSV file

##     category male female
## 1 Agegroup1   150    135
## 2  Agegroup2  100     90
## 3  Agegroup3  250    215
## 4      total  500    440

Slide with R Output

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Slide with Plot