Search code examples
rpdfrstudioknitrbeamer

Call Knit PDF (beamer) function from R file


Using RStudio Version 0.98.1103 I have a .Rmd file with some pre-populated markup (below).

Within RStudio I can click

Knit PDF > Knit PDF (Beamer)

and a PDF is generated. I would like to know how I can perform the same operation but within a .R file (essentially automating this process).

---
title: "Test"
author: "Test"
date: '2015-10-29'
output:
  beamer_presentation:
---

## R Markdown

This is an R Markdown presentation. 

## Slide with Bullets

- Bullet 1
- Bullet 2
- Bullet 3

## Slide with R Code and Output

```{r}
summary(cars)
```

## Slide with Plot

```{r, echo=FALSE}
plot(cars)
```

Solution

  • You can use render() from the rmarkdown package

    rmarkdown::render("your.Rmd")