Learn R Programming

⚠️There's a newer version (2.28) of this package.Take me there.

rmarkdown

The rmarkdown package helps you create dynamic analysis documents that combine code, rendered output (such as figures), and prose. You bring your data, code, and ideas, and R Markdown renders your content into a polished document that can be used to:

  • Do data science interactively within the RStudio IDE,

  • Reproduce your analyses,

  • Collaborate and share code with others, and

  • Communicate your results with others.

R Markdown documents can be rendered to many output formats including HTML documents, PDFs, Word files, slideshows, and more, allowing you to focus on the content while R Markdown takes care of your presentation.

Books

See more about them in Get Started.

Installation

The easiest way to install the rmarkdown package is from within the RStudio IDE, but you don't need to explicitly install it or load it, as RStudio automatically does both when needed. A recent version of Pandoc (>= 1.12.3) is also required; RStudio also automatically includes this too so you do not need to download Pandoc if you plan to use rmarkdown from the RStudio IDE.

If you want to use the rmarkdown package outside of RStudio, you can install the package from CRAN as follows:

install.packages("rmarkdown")

If you want to use the development version of the rmarkdown package (either with or without RStudio), you can install the package from GitHub via the remotes package:

# install.packages("pak")
pak::pak('rstudio/rmarkdown')

If not using the RStudio IDE, you'll need to install a recent version of Pandoc (>= 1.12.3); see the Pandoc installation instructions for help.

Usage

The easiest way to make a new R Markdown document is from within RStudio. Go to File > New File > R Markdown. From the new file wizard, you may:

  • Provide a document title (optional but recommended),
  • Provide an author name (optional but recommended),
  • Select a default output format- HTML is the recommended format for authoring, and you can switch the output format anytime (required),
  • Click OK (required).

Once inside your new .Rmd file, you should see some boilerplate text that includes code chunks. Use the "Knit" button in the RStudio IDE to render the file and preview the output with a single click or use the keyboard shortcut Cmd/Ctrl + Shift + K.

You can also delete all the text below the YAML frontmatter and fill in your own .Rmd by:

  • Adding code chunks (keyboard shortcut: Ctrl + Alt + I; OS X: Cmd + Option + I),
  • Writing prose with Markdown formatting, and
  • Running each code chunk interactively by clicking the icon within RStudio.

You can also click "Knit to HTML" again to render the full document with all code chunks. For more help getting started in R Markdown, please see the R Markdown website or use the "Get Started" links at the top of this page.

Getting help

There are two main places to get help:

  1. The RStudio community is a friendly place to ask any questions about rmarkdown and the R Markdown family of packages.

  2. Stack Overflow is a great source of answers to common rmarkdown questions. It is also a great place to get help, once you have created a reproducible example that illustrates your problem.

Code of Conduct

Please note that the rmarkdown project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Copy Link

Version

Install

install.packages('rmarkdown')

Monthly Downloads

1,078,184

Version

2.25

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

September 18th, 2023

Functions in rmarkdown (2.25)

beamer_presentation

Convert to a Beamer presentation
default_output_format

Determine the default output format for an R Markdown document
compile_notebook

Compiling R scripts to a notebook
draft

Create a new document based on a template
context_document

Convert to a ConTeXt document
html_fragment

Convert to an HTML fragment.
available_templates

List available R Markdown template in a package
html_vignette

Convert to an HTML vignette
includes

Include content within output
github_document

Convert to GitHub Flavored Markdown
html_notebook

Convert to an HTML notebook
metadata

The YAML metadata of the current R Markdown document
ioslides_presentation

Convert to an ioslides Presentation
knit_params_ask

Run a shiny application asking for parameter configuration for the given document.
knitr_options_pdf

Knitr options for a PDF output format
latex-dependencies

Provide common LaTeX dependencies
pandoc_self_contained_html

Create a self-contained HTML document using pandoc.
pandoc_template

Render a pandoc template.
odt_document

Convert to an OpenDocument Text (ODT) document
html_document

Convert to an HTML document
html-dependencies

Provide common HTML dependencies for R Markdown formats
html_document_base

Base output format for HTML-based output formats
latex_dependency

Define a LaTeX package dependency
md_document

Convert to a markdown document
knitr_options

Knitr options for an output format
navbar_html

Create a navbar HTML file from a navbar definition
output_format

Define an R Markdown output format
knitr_options_html

Knitr options for an HTML output format
pandoc_available

Check pandoc availability and version
pandoc_citeproc_convert

Convert a bibliograpy file
parse_html_notebook

Parse an HTML Notebook
paged_table

Create a table in HTML with support for paging rows and columns
pandoc_args

Functions for generating pandoc command line arguments
rtf_document

Convert to an RTF document
convert_ipynb

Convert a Jupyter/IPython notebook to an R Markdown document
run

Run a Shiny document
pandoc_options

Pandoc options for an output format
pdf_document

Convert to a PDF/LaTeX document
output_format_dependency

Define and merge an R Markdown's output format dependency
render

Render R Markdown
html_notebook_metadata

Generate R Notebook Metadata
pandoc_path_arg

Transform path for passing to pandoc
html_notebook_output

Generate R Notebook Output
pandoc_convert

Convert a document with pandoc
slidy_presentation

Convert to a slidy presentation
output_metadata

The output metadata object
pkg_file_lua

Get the full paths of Lua filters in an R package
rmarkdown_format

R Markdown input format definition
word_document

Convert to an MS Word document
powerpoint_presentation

Convert to a PowerPoint presentation
pandoc_exec

Get the path of the pandoc executable
publish_site

Publish an R Markdown Website
relative_to

Relative path utility function
resolve_output_format

Resolve the output format for an R Markdown document
rmd_metadata

R Markdown Metadata
render_delayed

Delay Rendering for an Expression
yaml_front_matter

Parse the YAML front matter from a file
shiny_prerendered_chunk

Add code to a shiny_prerendered context
render_site

Render multiple documents as a website
render_supporting_files

Render supporting files for an input document
shiny_prerendered_server_start_code

Get the server startup code for a shiny_prerendered server instance
site_resources

Determine website resource files for a directory
shiny_prerendered_clean

Clean prerendered content for the specified Rmd input file
rmarkdown-package

R Markdown Document Conversion
find_pandoc

Find the pandoc executable
all_output_formats

Determine all output formats for an R Markdown document
find_external_resources

Find External Resource References