R Markdown for Reproducible Reports

R Markdown blends executable R code chunks with Markdown narrative to produce dynamic reports, slides, web pages, and notebooks. It works seamlessly within RStudio / Posit.

Getting Started & Resources

To begin, open RStudio and select File → New File → R Markdown (HTML, PDF, or Word) or R Notebook. Click the Knit button in the editor toolbar to render the document.

Adding Pandoc to Your PATH (macOS / Linux)

If running knitr from the terminal or shell scripts outside RStudio:

export PATH=$PATH:/Applications/RStudio.app/Contents/MacOS/quarto/bin:/Applications/RStudio.app/Contents/MacOS/pandoc

Interactive Syntax & Example Report

Document Structure & Typography

Regular text, non-code.

      How to indent text

You can italicize things. You can bold things. Notice how a single paragraph break shows up as a space.

##Slightly smaller sub-header

###Even smaller sub-header

####You get the idea

Including a link http://cran.mtu.edu/ ⚠️

#This all shows up in a "code" grey box
#Code will be automatically colored to highlight file names, command modifiers, etc.
myData = data.frame(replicate(10,sample(0:1,1000,rep=TRUE)))

Next large header

You can include the output of some in-line code like: The dimensions of my data are 1000, 10

And you can also include the actual in-line code like dim(myData)

Making some figures

hist(myData$X1)

plot of chunk MakeSomePlots

Modifying all figures in a chunk with parameters in the chunk header

hist(myData$X2)

plot of chunk AddSomePlotParameters

hist(myData$X3)

plot of chunk AddSomePlotParameters

Analyzing some data

This option only shows the output, not the code

## [1] 0.8907865

This option only shows the code, not the output

x <- rnorm(100)
y <- 2*x + rnorm(100)
cor(x, y)

This option evaluates the code but neither code nor output is displayed


This site uses Just the Docs, a documentation theme for Jekyll.