ID 529: Data Management and Analytic Workflows in R
Dean Marengi | Tuesday, January 16th, 2024
.html
, .docx
, .pdf
and more)gtsummary
, sjPlot
, stargazer
, and ggstatsplot
in R MarkdownR
)
Note: Markdown is the syntax you use to edit README files on GitHub!
# Markdown: a love story
There's a beauty in the *simplicity* of formatting text with `Markdown`! It's capable of giving so much, ***while asking for so little***. Not like those text formatting tools from "**Big Word Processor,**" with all of their fancy bells and whistles.
## What's great about Markdown, you ask?
- It's easy to read and write
- It's platform-agnostic
- No specific software required
- Highly compatiable with a range of tools
- Overall, less fuss!
Rendered output on the next slide!
There’s a beauty in the simplicity of formatting text with Markdown! It’s capable of giving so much, while asking for so little. Not like those text formatting tools from “Big Word Processor”, with all of their fancy bells and whistles.
Great tool for promoting transparency and reproducible research, as it allows researchers to easily consolidate their code, results, and interpretations into a single document!
.Rmd
files as .qmd
files.Rmd
) are plain text files designed to contain three types of content:
{r}
and ```.Rmd
file---
and ---
---
title: "Reproducible Research"
author: "A prudent researcher"
date: "2024-01-16"
output: html_document
---
---
title: "Reproducible Research"
author: "A prudent researcher"
date: "2024-01-16"
output:
pdf_document: default
html_document: default
word_document: default
github_document: default
---
pdf
, html
, or docx
).Rmd
file
Markdown text
# Level 1 header
## Level 2 header
### Level 3 header
#### Level 4 header
Rendered text
Markdown text
*italics* or _italics_
**bold** or __bold__
***bold and italic*** or
___bold and italic___
~~strikethrough~~
superscripts^2^
Rendered text
italics or italics
bold or bold
bold and italic or
bold and italic
strikethrough
superscripts2
Markdown text
- item 1
- item 2
- item 3
- item 3.1
- item 3.2
- item 3.2.1
1. item 1
2. item 2
3. item 3
- item 3.1
- item 3.2
- item 3.2.1
Rendered text
Markdown text
* item 1
* item 2
* item 3
+ item 3.1
+ item 3.2
+ item 3.2.1
1. item 1
2. item 2
3. item 3
+ item 3.1
+ item 3.2
+ item 3.2.1
Rendered text
Markdown text
> "Block quotes are neat."
>
> -- Hodu
Rendered text
“Block quotes are neat.”
– Hodu
Markdown text
https://id529.github.io
[ID 529 Website (current window)](https://id529.github.io)
[ID 529 Course Website (new window)](https://id529.github.io){target="_blank"}
Rendered text
Images from file storage
![](images/hex-rmarkdown.png)
Images from web sources
![](https://i0.wp.com/johnmackintosh.net/assets/img/blog/20220921-padme.jpeg)
knitr
chunk options
{r ...}
include = FALSE
: Exclude chunk code/outputecho = FALSE
: Show code output, but not the codewarning = FALSE
: Don’t include warning messagesfig.height = ...
: Set output figure height (in.)fig.width = ...
: Set output figure width (in.)See the resources linked below for more; there are a lot!
chunk options
for each code chunk, you can alternatively set global chunk options
Rmd
document
Note: If you want to create pdf reports, you will need to install a LaTeX
distribution. For R, it’s recommended that the TinyTex distribution be used. To do this, you can install the tinytex
R package. Check out the resources linked below for more details.
LaTeX
syntax
$..$
are displayed “in-line”$$..$$
render as stand-alone equations$$
\begin{equation}
\hat{Y}_i = \hat{\beta}_0 + \hat{\beta}_1 X_i + \hat{\epsilon}_i
\end{equation}
$$
This is some text with an in-line expressions like $\hat{Y}_i$ and $\hat{\beta}_1 X_i$. Pretty cool, right?
\[ \begin{equation} \hat{Y}_i = \hat{\beta}_0 + \hat{\beta}_1 X_i + \hat{\epsilon}_i \end{equation} \] This is some text with an in-line expressions like \(\hat{Y}_i\) and \(\hat{\beta}_1 X_i\). Pretty cool, right?
Introductory Information
Resources to quickly reference
More comprehensive resources