You are on page 1of 10

Introductory Session

Introduction to R
Markdown

Sandip Mukhopadhyay
What is Markdown

Markdown is a text-to-HTML conversion tool for web writers.

Markdown allows you to write using easy-to-read, easy-to-write plain text


format, then convert it to structurally valid HTML.

It is a simple formatting tool that converts plain text to HTML format.


What is R Markdown?

R Markdown combines the core syntax of markdown with embedded R code


chunks to create dynamic documents without much effort.

With R markdown, we can combine R codes, plots and text to create


beautiful reports and presentation.

The reports can be generated in different formats such as


» HTML
» PDF
» Word
R Markdown File

It would have
• Code
• Text
• Metadata

• YAML.
• YAML is a syntax for hierarchical data structure.
• It contains the metadata of the file, stored in key-value pair
• The metadata can be modified, other than the format type.
R Markdown File
R Markdown File- Text

Plain Text typed would remain plain text

End a line with two spaces, to start a new line

End a line with \ to start a new line

Header can be created using # character.

**bold** or _ _ to make the text bold.

*bold* or _bold_ to make the text Italic.

~~bold~~ to make it strikethrough


R Markdown File- R code

For datafile, type the entire path of the directory.

Donot include any help function.


#Code Chunk Option
Chunk output can be customized with knitr options,
arguments set in the {} of a chunk header.

• include = FALSE prevents code and results from appearing in


the finished file. R Markdown still runs the code in the chunk,
and the results can be used by other chunks.
• echo = FALSE prevents code, but not the results from
appearing in the finished file. This is a useful way to embed
figures.
#Code Chunk Option

• message = FALSE prevents messages that are generated by


code from appearing in the finished file.
• warning = FALSE prevents warnings that are generated by
code from appearing in the finished.
#What is Knitting?

• Knitting a file allows us to generate an output file


from R Markdown format.

• When the knitting is done, R Markdown executes


the R code chunk and combines them, the output
with text available in the R markdown document
and transforms it to a HTML file.

You might also like