# According to R Studio

“R Markdown is a format that enables easy authoring of reproducible web reports from R. It combines the core syntax of Markdown (an easy-to-write plain text format for web content) with embedded R code chunks that are run so their output can be included in the final document”.

# From Penn State Statistics

Introduction to creating dynamic R statistical reports in PDF or HTML:

## What do you mean by dynamic?

The traditional way to write a report is:

1. Run your analysis in software, like SPSS or R and manually save our output
• i.e. saving the ANOVA table or using pdf() to save the graphs
2. Type your your description and interpretation in a text editor like Word
• either drag/drop tables and figures, or worse copy-paste and retype all the numbers

A report written in this way can be problematic. For instance, imagine your Mentor/collaborator/journal reviewer telling you that they want to use a sub-sample instead of the entire sample. Or to include a nother variable. You would have to redo all of your work!!

Therefore, in this way dynamic also means reproducible, in the sense that people who get the file from you can reproduce the entire work in the report.

## How does R Markdown work out to be a .pdf or .html file?

R Markdown is a file with the file extension .Rmd, the knitr package will then transform the file into a Markdown file with the extension .md. Then Rstudio can:

• Use LaTeX to transform the file into a .pdf

• Load another package called markdown to transform the file into .html

• Use Pandoc to even convert to file to a Word document (ugly)

## Background Information

R Markdown documents are fully reproducible. Use a productive notebook interface to weave together narrative text and code to produce elegantly formatted output. Use multiple languages including R, Python, and SQL.

knitr is an engine for dynamic report generation with R. It is a package in the statistical programming language R that enables integration of R code into LaTeX, LyX, HTML, Markdown, AsciiDoc, and text documents.

## 1. R from www.r-project.org

Get the latest released version of FREE Base R from CRAN

• Choose a mirror close to your location
• Select base R for your computer (Windows, Mac, ect.)
• The defaults are good…don’t change them…just keep clicking ‘Next’

## 2 R Studio from www.rstudio.com

Get the latest version of the FREE Open Source Desktop Edition of R Studio

• The defaults are good…don’t change them…just keep clicking ‘Next’

## 3. LaTeX depends on your operating system

Mac: MacTeX from http://tug.org/mactex/

• Download (5+ min) to a folder and them double click on the PKG file
Windows: MikTeX http://miktex.org/download