R Markdown is a powerful tool for creating dynamic documents that integrate code, text, and visualizations as well as for creating reproducible reports. By combining text, code, and output in a single document, you can effectively communicate your data analysis results.
Ensure you have R and RStudio installed. Then, install the
rmarkdown package as well as any other package that your
code will need to use:
install.packages("rmarkdown")
File > New File >
R Markdown....OK to create the document.An R Markdown document consists of three main parts:
---
title: "My First R Markdown"
author: "Your Name"
date: "October 3, 2024"
output: html_document
---
## Introduction
This is a simple R Markdown document.
{r}.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
Download this file titled ``tutorial-markdown.Rmd” and open it in your R Studio. You will see that the code that generates the above embedded R code and output. If you simply open this.Rmd file and then render it by clicking on “Knit”, you will have the output file.
Knit button in RStudio to render the document
into the selected output format.output:
html_document:
toc: true
toc_depth: 2