LinuxCommandLibrary

rmarkdown

TLDR

Render R Markdown to HTML

$ Rscript -e "rmarkdown::render('[file.Rmd]')"
copy
Render to PDF
$ Rscript -e "rmarkdown::render('[file.Rmd]', output_format='pdf_document')"
copy
Render to Word
$ Rscript -e "rmarkdown::render('[file.Rmd]', output_format='word_document')"
copy
Render with parameters
$ Rscript -e "rmarkdown::render('[file.Rmd]', params=list(year=2024))"
copy

SYNOPSIS

R Markdown document processing

DESCRIPTION

R Markdown combines R code with Markdown text to create dynamic documents. It can produce HTML, PDF, Word documents, presentations, dashboards, and more.

EXAMPLES

$ # In R
library(rmarkdown)
render("report.Rmd")

# Specify output
render("report.Rmd", output_format = "pdf_document")

# With parameters
render("report.Rmd", params = list(data = "sales.csv"))
copy

YAML HEADER

$ ---
title: "My Report"
author: "Name"
date: "`r Sys.Date()`"
output:
  html_document:
    toc: true
    theme: united
---
copy

CODE CHUNKS

$
copy
knitr::opts_chunk$set(echo = TRUE)
$
copy
plot(cars)
$
copy

OUTPUT FORMATS

$ html_document
pdf_document (requires LaTeX)
word_document
ioslides_presentation
beamer_presentation
flexdashboard
copy

CAVEATS

Requires R and rmarkdown package. PDF needs LaTeX (tinytex). Processing can be slow.

HISTORY

R Markdown was developed by RStudio (now Posit) building on knitr by Yihui Xie.

SEE ALSO

Rscript(1), knitr(1), pandoc(1)

Copied to clipboard