SlideShare a Scribd company logo
www.r-squared.in/git-hub
R2
Academy
RMarkdown Tutorial For
Beginners
R2
AcademyCourse Material
Slide 2
All the material related to this course are available on our website
Scripts can be downloaded from GitHub
Videos can be viewed on our Youtube Channel
R2
AcademyTable Of Contents
Slide 3
✓ Objectives
✓ Markdown
✓ R Markdown
✓ Syntax
➢ Headers
➢ Emphasis
➢ Lists
➢ Links
➢ Images
➢ Code Chunks
✓ RStudio Settings
✓ References
R2
AcademyLearning Objectives
Slide 4
→ What is Markdown?
→ What is R Markdown?
→ Markdown Syntax
→ RStudio Settings
R2
Academy
Slide 5
What is Markdown?
R2
AcademyWhat is Markdown?
Slide 6
Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write
using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid
XHTML (or HTML).
- John Gruber, creator of Markdown
Markdown is a simple formatting syntax that makes authoring web content easy. It is a
software tool that converts plain text formatting to HTML and is written in Perl.
R2
Academy
Slide 7
What is R Markdown?
R2
AcademyWhat is R Markdown?
Slide 8
R Markdown combines the core syntax of markdown with embedded R code chunks to create
dynamic documents. It enables easy creation of dynamic documents, reports and
presentations which are fully reproducible.
With R Markdown we can combine R codes, plots and text to create beautiful reports and
presentations. The reports can be generated in different formats such as:
● PDF
● MS Word
● HTML
The best part about R Markdown is when you have to make some changes to your codes or
the underlying data and recreate the entire document. You can make the necessary changes
and R Markdown will recreate the document with just a single click.
R2
Academy
Slide 9
Markdown Syntax
R2
AcademyMarkdown Syntax
Slide 10
→ Headers
→ Emphasis
→ Lists
→ Links
→ Images
→ Code Chunks
R2
AcademyHeaders
Slide 11
Markdown HTML Output
# Markdown <h1>Markdown</h1>
Markdown
## Markdown <h2>Markdown</h2>
Markdown
### Markdown <h3>Markdown</h3> Markdown
#### Markdown <h4>Markdown</h4> Markdown
##### Markdown <h5>Markdown</h5> Markdown
###### Markdown <h6>Markdown</h6> Markdown
Headers in Markdown are denoted by the hash character. You can create six levels of headers by
using the hash characters.
R2
AcademyEmphasis
Slide 12
Asterisks ‘*’ or underscores ‘_’ are used to indicate emphasis. Similarly, double
asterisks ‘**’ or double underscores ‘__’ are used to indicate bold.
Markdown HTML Output
*Markdown* <em>Markdown</em> Markdown
_Markdown_ <em>Markdown</em> Markdown
**Markdown** <b>Markdown</b> Markdown
__Markdown_ <b>Markdown</b> Markdown
R2
Academy
Slide 13
Lists
R2
AcademyUnordered Lists
Slide 14
Unordered lists can be created using asterisks ‘*’ or hyphens ‘-’ or pluses ‘+’.
Markdown HTML Output
★ One
★ Two
★ Three
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
● One
● Two
● Three
- One
- Two
- Three
+ One
+ Two
+ Three
R2
AcademyOrdered Lists
Slide 15
Unordered lists can be created using numbers.
Markdown HTML Output
1. One
2. Two
3. Three
<ol>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ol>
1. One
2. Two
3. Three
R2
Academy
Slide 16
Links
R2
AcademyExternal Links
Slide 17
Links to external objects can be created using the following syntax:
Markdown HTML Output
[RStudio](http://www.rstudio.
com/)
<a href=”http://www.rstudio.com/”
>RStudio</a>
RStudio
[Link Title](Link URL)
R2
AcademyInternal Links
Links to sections within a document can be created using the following syntax:
The section identifier must be placed alongside the link and the section title. Keep in mind that there should not be any
space in the section identifier and they must be unique.
[Link Title1](#SectionIdentifier1)
[Link Title2](#SectionIdentifier2)
[Section Title1](#SectionIdentifier1)
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec pretium mi
ligula, quis luctus metus vulputate sed. Donec tincidunt est mauris, nec
auctor lectus pretium finibus. Praesent finibus elit odio. Cum sociis natoque
penatibus et magnis dis parturient montes, nascetur ridiculus mus.
[Section Title2](#SectionIdentifier2)
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec pretium mi
ligula, quis luctus metus vulputate sed. Donec tincidunt est mauris, nec
auctor lectus pretium finibus. Praesent finibus elit odio.
Table of Contents
Introduction(#intro)
Data Visualization(#dataviz)
Introduction(#intro)
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec pretium mi
ligula, quis luctus metus vulputate sed. Donec tincidunt est mauris, nec auctor
lectus pretium finibus. Praesent finibus elit odio. Cum sociis natoque
penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Data Visualization(#dataviz)
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec pretium mi
ligula, quis luctus metus vulputate sed. Donec tincidunt est mauris, nec auctor
lectus pretium finibus. Praesent finibus elit odio. Cum sociis natoque
penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Slide 18
R2
Academy
Images
Slide 19
R2
AcademyImages
Images can be inserted using the below syntax:
Markdown HTML
![RStudio](rstudio.jpg) <img src="rstudio.jpg" alt="RStudio">
![alt text](path/image)
Slide 20
R2
Academy
Code Chunks
Slide 21
R2
AcademyIntroduction
Slide 22
It is when creating reports that contain
R codes and outputs that we will
appreciate markdown the most. It saves
us from cut/copy/paste ritual while
saving time and minimising errors.
Whenever the code or data changes,
markdown will automatically regenerate
the whole document with the updated
outputs and therein lies its magic.
R2
AcademyInserting Code Chunks
Slide 23
Inserting code chunks in RStudio is very simple. Open a new R Markdown file and on the right hand side you will
find a drop down named Chunks. Click on it and select the option Insert Chunk or alternatively press Ctrl +
Alt + I.
We will understand the syntax of code chunks using the below example:
There are three parts that we need to understand:
R2
AcademySyntax
Slide 24
```{r}
# summary of mtcars data set
summary(cars)
```
Part Description
``` All R codes must be enclosed by the 3 backticks.
{} The term r and output options go here.
Code All the codes/comments go between {} and the second backtick.
There are lots of options available in R Markdown for using codes and their outputs in a document.
We will explore the most important ones:
R2
AcademyOptions
Slide 25
Option Description Example
echo If FALSE, will display only output and not the code
itself.
```{r, echo = FALSE}
summary(mtcars)
```
results If ‘hide’, will display only the code and not the result ```{r, results= hide}
summary(mtcars)
```
fig.height
fig.width
Set the dimensions of a plot. ```{r, fig.width = 4, fig.height = 4}
plot(mtcars$mpg)
```
fig.align Modify the position of the plot. ```{r, fig.align = ‘center’}
plot(mtcars$mpg)
```
R2
Academy
Slide 26
RStudio Settings
R2
AcademyGlobal Options
Slide 27
Go To: Tools > Global Options > Sweave
● Ensure that pdfLaTeX or XeLaTeX is
selected against Typeset Latex into
PDF using: as this will be crucial
while generating PDF documents and
presentations.
● Sumatra is selected in the PDF
Preview section (it will be used for
previewing all the PDF documents
generated).
R2
AcademyPackages
Slide 28
# install the following packages
> install.packages(“rmarkdown”, “knitr”)
# load the libraries
> library(rmarkdown)
> library(knitr)
Install and load the rmarkdown and knitr packages. The current version of R Markdown is
based on knitr and pandoc.
R2
AcademyReferences
Slide 29
Click the below links to learn more about:
➢ Markdown
➢ R Markdown
➢ R Markdown Cheat Sheet
➢ R Markdown Reference Guide
R2
Academy
Slide 30
Visit Rsquared Academy
for tutorials on:
→ R Programming
→ Business Analytics
→ Data Visualization
→ Web Applications
→ Package Development
→ Git & GitHub

More Related Content

PDF
Linear Regression With R
PPTX
Step By Step Guide to Learn R
PPTX
Unit 1 - R Programming (Part 2).pptx
PDF
Introduction to R Programming
PDF
Data Visualization With R
PPTX
Getting Started with R
PPTX
Data visualization using R
PDF
7. Data Import – Data Export
 
Linear Regression With R
Step By Step Guide to Learn R
Unit 1 - R Programming (Part 2).pptx
Introduction to R Programming
Data Visualization With R
Getting Started with R
Data visualization using R
7. Data Import – Data Export
 

What's hot (20)

PPTX
Data visualization with R
PPT
R programming slides
PDF
4 Descriptive Statistics with R
KEY
NumPy/SciPy Statistics
PDF
R data types
PPTX
Introduction to R programming
PPTX
PPTX
Data Management in R
PPTX
R programming
PPTX
Workshop presentation hands on r programming
PPTX
random forest regression
PDF
R Programming: Introduction to Matrices
PDF
Class ppt intro to r
PDF
R Programming: Introduction To R Packages
PPTX
Normalization 1 nf,2nf,3nf,bcnf
PPTX
R Programming: Variables & Data Types
PPTX
Python Seaborn Data Visualization
PPTX
MODULE 1_Introduction to Data analytics and life cycle..pptx
PPTX
Data analysis with R
PPTX
R programming Fundamentals
Data visualization with R
R programming slides
4 Descriptive Statistics with R
NumPy/SciPy Statistics
R data types
Introduction to R programming
Data Management in R
R programming
Workshop presentation hands on r programming
random forest regression
R Programming: Introduction to Matrices
Class ppt intro to r
R Programming: Introduction To R Packages
Normalization 1 nf,2nf,3nf,bcnf
R Programming: Variables & Data Types
Python Seaborn Data Visualization
MODULE 1_Introduction to Data analytics and life cycle..pptx
Data analysis with R
R programming Fundamentals
Ad

Similar to R Markdown Tutorial For Beginners (20)

PDF
MLflow with R
PDF
R package development, create package documentation isabella gollini
PPTX
C:\Fakepath\Combating Software Entropy 2
PPTX
C:\Fakepath\Combating Software Entropy 2
PDF
DTP Certification
PDF
Consequences of using the Copy-Paste method in C++ programming and how to dea...
PPT
Higher isdd revision presentation
PDF
Introduction to R
PDF
Rmarkdown cheatsheet-2.0
PDF
"Technical Challenges behind Visual IDE for React Components" Tetiana Mandziuk
PDF
React Native Workshop - React Alicante
DOCX
Decorating code (Research Paper)
PPT
A intro to (hosted) Shiny Apps
PDF
The Dynamic Language is not Enough
PDF
Building DSLs On CLR and DLR (Microsoft.NET)
DOCX
Computer fundamentals
PDF
How to-code-r
PDF
[1D6]RE-view of Android L developer PRE-view
PPTX
Improving Code Quality Through Effective Review Process
PDF
Euro python 2015 writing quality code
MLflow with R
R package development, create package documentation isabella gollini
C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2
DTP Certification
Consequences of using the Copy-Paste method in C++ programming and how to dea...
Higher isdd revision presentation
Introduction to R
Rmarkdown cheatsheet-2.0
"Technical Challenges behind Visual IDE for React Components" Tetiana Mandziuk
React Native Workshop - React Alicante
Decorating code (Research Paper)
A intro to (hosted) Shiny Apps
The Dynamic Language is not Enough
Building DSLs On CLR and DLR (Microsoft.NET)
Computer fundamentals
How to-code-r
[1D6]RE-view of Android L developer PRE-view
Improving Code Quality Through Effective Review Process
Euro python 2015 writing quality code
Ad

More from Rsquared Academy (20)

PDF
Handling Date & Time in R
PDF
Market Basket Analysis in R
PDF
Practical Introduction to Web scraping using R
PDF
Joining Data with dplyr
PDF
Explore Data using dplyr
PDF
Data Wrangling with dplyr
PDF
Writing Readable Code with Pipes
PDF
Introduction to tibbles
PDF
Read data from Excel spreadsheets into R
PDF
Read/Import data from flat/delimited files into R
PDF
Variables & Data Types in R
PDF
How to install & update R packages?
PDF
How to get help in R?
PDF
Introduction to R
PDF
RMySQL Tutorial For Beginners
PDF
R Data Visualization Tutorial: Bar Plots
PDF
R Programming: Introduction to Vectors
PDF
Data Visualization With R: Learn To Combine Multiple Graphs
PDF
R Data Visualization: Learn To Add Text Annotations To Plots
PDF
Data Visualization With R: Learn To Modify Font Of Graphical Parameters
Handling Date & Time in R
Market Basket Analysis in R
Practical Introduction to Web scraping using R
Joining Data with dplyr
Explore Data using dplyr
Data Wrangling with dplyr
Writing Readable Code with Pipes
Introduction to tibbles
Read data from Excel spreadsheets into R
Read/Import data from flat/delimited files into R
Variables & Data Types in R
How to install & update R packages?
How to get help in R?
Introduction to R
RMySQL Tutorial For Beginners
R Data Visualization Tutorial: Bar Plots
R Programming: Introduction to Vectors
Data Visualization With R: Learn To Combine Multiple Graphs
R Data Visualization: Learn To Add Text Annotations To Plots
Data Visualization With R: Learn To Modify Font Of Graphical Parameters

Recently uploaded (20)

PPTX
STUDY DESIGN details- Lt Col Maksud (21).pptx
PPTX
climate analysis of Dhaka ,Banglades.pptx
PDF
Fluorescence-microscope_Botany_detailed content
PPTX
IBA_Chapter_11_Slides_Final_Accessible.pptx
PDF
Business Analytics and business intelligence.pdf
PPTX
Computer network topology notes for revision
PPTX
IB Computer Science - Internal Assessment.pptx
PPT
ISS -ESG Data flows What is ESG and HowHow
PPTX
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
PPTX
Business Ppt On Nestle.pptx huunnnhhgfvu
PDF
Lecture1 pattern recognition............
PPTX
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
PPTX
Database Infoormation System (DBIS).pptx
PPTX
Supervised vs unsupervised machine learning algorithms
PPTX
Business Acumen Training GuidePresentation.pptx
PPTX
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
PPT
Reliability_Chapter_ presentation 1221.5784
PPTX
Introduction-to-Cloud-ComputingFinal.pptx
PPTX
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
PPTX
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
STUDY DESIGN details- Lt Col Maksud (21).pptx
climate analysis of Dhaka ,Banglades.pptx
Fluorescence-microscope_Botany_detailed content
IBA_Chapter_11_Slides_Final_Accessible.pptx
Business Analytics and business intelligence.pdf
Computer network topology notes for revision
IB Computer Science - Internal Assessment.pptx
ISS -ESG Data flows What is ESG and HowHow
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
Business Ppt On Nestle.pptx huunnnhhgfvu
Lecture1 pattern recognition............
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
Database Infoormation System (DBIS).pptx
Supervised vs unsupervised machine learning algorithms
Business Acumen Training GuidePresentation.pptx
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
Reliability_Chapter_ presentation 1221.5784
Introduction-to-Cloud-ComputingFinal.pptx
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj

R Markdown Tutorial For Beginners

  • 2. R2 AcademyCourse Material Slide 2 All the material related to this course are available on our website Scripts can be downloaded from GitHub Videos can be viewed on our Youtube Channel
  • 3. R2 AcademyTable Of Contents Slide 3 ✓ Objectives ✓ Markdown ✓ R Markdown ✓ Syntax ➢ Headers ➢ Emphasis ➢ Lists ➢ Links ➢ Images ➢ Code Chunks ✓ RStudio Settings ✓ References
  • 4. R2 AcademyLearning Objectives Slide 4 → What is Markdown? → What is R Markdown? → Markdown Syntax → RStudio Settings
  • 6. R2 AcademyWhat is Markdown? Slide 6 Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML). - John Gruber, creator of Markdown Markdown is a simple formatting syntax that makes authoring web content easy. It is a software tool that converts plain text formatting to HTML and is written in Perl.
  • 8. R2 AcademyWhat is R Markdown? Slide 8 R Markdown combines the core syntax of markdown with embedded R code chunks to create dynamic documents. It enables easy creation of dynamic documents, reports and presentations which are fully reproducible. With R Markdown we can combine R codes, plots and text to create beautiful reports and presentations. The reports can be generated in different formats such as: ● PDF ● MS Word ● HTML The best part about R Markdown is when you have to make some changes to your codes or the underlying data and recreate the entire document. You can make the necessary changes and R Markdown will recreate the document with just a single click.
  • 10. R2 AcademyMarkdown Syntax Slide 10 → Headers → Emphasis → Lists → Links → Images → Code Chunks
  • 11. R2 AcademyHeaders Slide 11 Markdown HTML Output # Markdown <h1>Markdown</h1> Markdown ## Markdown <h2>Markdown</h2> Markdown ### Markdown <h3>Markdown</h3> Markdown #### Markdown <h4>Markdown</h4> Markdown ##### Markdown <h5>Markdown</h5> Markdown ###### Markdown <h6>Markdown</h6> Markdown Headers in Markdown are denoted by the hash character. You can create six levels of headers by using the hash characters.
  • 12. R2 AcademyEmphasis Slide 12 Asterisks ‘*’ or underscores ‘_’ are used to indicate emphasis. Similarly, double asterisks ‘**’ or double underscores ‘__’ are used to indicate bold. Markdown HTML Output *Markdown* <em>Markdown</em> Markdown _Markdown_ <em>Markdown</em> Markdown **Markdown** <b>Markdown</b> Markdown __Markdown_ <b>Markdown</b> Markdown
  • 14. R2 AcademyUnordered Lists Slide 14 Unordered lists can be created using asterisks ‘*’ or hyphens ‘-’ or pluses ‘+’. Markdown HTML Output ★ One ★ Two ★ Three <ul> <li>One</li> <li>Two</li> <li>Three</li> </ul> ● One ● Two ● Three - One - Two - Three + One + Two + Three
  • 15. R2 AcademyOrdered Lists Slide 15 Unordered lists can be created using numbers. Markdown HTML Output 1. One 2. Two 3. Three <ol> <li>One</li> <li>Two</li> <li>Three</li> </ol> 1. One 2. Two 3. Three
  • 17. R2 AcademyExternal Links Slide 17 Links to external objects can be created using the following syntax: Markdown HTML Output [RStudio](http://www.rstudio. com/) <a href=”http://www.rstudio.com/” >RStudio</a> RStudio [Link Title](Link URL)
  • 18. R2 AcademyInternal Links Links to sections within a document can be created using the following syntax: The section identifier must be placed alongside the link and the section title. Keep in mind that there should not be any space in the section identifier and they must be unique. [Link Title1](#SectionIdentifier1) [Link Title2](#SectionIdentifier2) [Section Title1](#SectionIdentifier1) Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec pretium mi ligula, quis luctus metus vulputate sed. Donec tincidunt est mauris, nec auctor lectus pretium finibus. Praesent finibus elit odio. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. [Section Title2](#SectionIdentifier2) Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec pretium mi ligula, quis luctus metus vulputate sed. Donec tincidunt est mauris, nec auctor lectus pretium finibus. Praesent finibus elit odio. Table of Contents Introduction(#intro) Data Visualization(#dataviz) Introduction(#intro) Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec pretium mi ligula, quis luctus metus vulputate sed. Donec tincidunt est mauris, nec auctor lectus pretium finibus. Praesent finibus elit odio. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Data Visualization(#dataviz) Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec pretium mi ligula, quis luctus metus vulputate sed. Donec tincidunt est mauris, nec auctor lectus pretium finibus. Praesent finibus elit odio. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Slide 18
  • 20. R2 AcademyImages Images can be inserted using the below syntax: Markdown HTML ![RStudio](rstudio.jpg) <img src="rstudio.jpg" alt="RStudio"> ![alt text](path/image) Slide 20
  • 22. R2 AcademyIntroduction Slide 22 It is when creating reports that contain R codes and outputs that we will appreciate markdown the most. It saves us from cut/copy/paste ritual while saving time and minimising errors. Whenever the code or data changes, markdown will automatically regenerate the whole document with the updated outputs and therein lies its magic.
  • 23. R2 AcademyInserting Code Chunks Slide 23 Inserting code chunks in RStudio is very simple. Open a new R Markdown file and on the right hand side you will find a drop down named Chunks. Click on it and select the option Insert Chunk or alternatively press Ctrl + Alt + I.
  • 24. We will understand the syntax of code chunks using the below example: There are three parts that we need to understand: R2 AcademySyntax Slide 24 ```{r} # summary of mtcars data set summary(cars) ``` Part Description ``` All R codes must be enclosed by the 3 backticks. {} The term r and output options go here. Code All the codes/comments go between {} and the second backtick.
  • 25. There are lots of options available in R Markdown for using codes and their outputs in a document. We will explore the most important ones: R2 AcademyOptions Slide 25 Option Description Example echo If FALSE, will display only output and not the code itself. ```{r, echo = FALSE} summary(mtcars) ``` results If ‘hide’, will display only the code and not the result ```{r, results= hide} summary(mtcars) ``` fig.height fig.width Set the dimensions of a plot. ```{r, fig.width = 4, fig.height = 4} plot(mtcars$mpg) ``` fig.align Modify the position of the plot. ```{r, fig.align = ‘center’} plot(mtcars$mpg) ```
  • 27. R2 AcademyGlobal Options Slide 27 Go To: Tools > Global Options > Sweave ● Ensure that pdfLaTeX or XeLaTeX is selected against Typeset Latex into PDF using: as this will be crucial while generating PDF documents and presentations. ● Sumatra is selected in the PDF Preview section (it will be used for previewing all the PDF documents generated).
  • 28. R2 AcademyPackages Slide 28 # install the following packages > install.packages(“rmarkdown”, “knitr”) # load the libraries > library(rmarkdown) > library(knitr) Install and load the rmarkdown and knitr packages. The current version of R Markdown is based on knitr and pandoc.
  • 29. R2 AcademyReferences Slide 29 Click the below links to learn more about: ➢ Markdown ➢ R Markdown ➢ R Markdown Cheat Sheet ➢ R Markdown Reference Guide
  • 30. R2 Academy Slide 30 Visit Rsquared Academy for tutorials on: → R Programming → Business Analytics → Data Visualization → Web Applications → Package Development → Git & GitHub