Skip to main content
Contents Index
Dark Mode Prev Up Next
\(\require{cancel}
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Section B.8 Key Takeaways
R Markdown allows you to combine code, narrative text, and output in a single document, making analyses easier to understand, share, and reproduce.
While an R script can be reproducible, R Markdown improves reproducibility by clearly linking analysis decisions, results, and interpretation in one place.
Every R Markdown document is structured around three core components: YAML metadata, text, and R code chunks.
The YAML section controls important document-level information such as the title, author, date, and output format.
Text in R Markdown is written using Markdown syntax, allowing you to format headings, lists, emphasis, links, images, and quotes without writing code.
All R code must be written inside R chunks, which behave like a mini R script and are executed from top to bottom when the document is knitted.
Naming R chunks helps organize your analysis and prevents errors during knitting.
Calling objects, functions, or plots inside a chunk automatically displays their output in the final document.
Functions like kable() allow you to present tables in a cleaner, more readable format than raw console output.
Knitting an R Markdown file runs the entire document in a clean environment, which helps identify missing objects, forgotten packages, and reproducibility issues.
Publishing an R Markdown document allows you to share your work beyond R, turning analyses into polished, shareable artifacts.
This chapter brings together everything from earlier chapters, showing how data manipulation, visualization, and analysis can be communicated clearly and reproducibly in a final report.