Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert RStudio presentation (.Rpres) to rmarkdown presentation (.Rmd)

Currently there seem to be two ways to do presentations in R:

  • RStudio presentations, with .Rpres extension
  • rmarkdown, with .Rmd extension

To me, it looks like the latter is slightly more powerful. The input format is very similar, yet not identical. I'm thinking about converting an RStudio presentation to rmarkdown. What's the best way to do this? How about the conversion back?

On that note, I'd really like to see an "in-pane" preview for rmarkdown presentations in RStudio, just like for RStudio presentations. I wonder why this isn't implemented -- the preview forcibly shows up in a modal window. Technical issues?

like image 355
krlmlr Avatar asked Sep 11 '14 15:09

krlmlr


People also ask

How do I change R to Markdown in R?

If you use the RStudio IDE, the keyboard shortcut to render R scripts is the same as when you knit Rmd documents ( Ctrl / Cmd + Shift + K ). When rendering an R script to a report, the function knitr::spin() is called to convert the R script to an Rmd file first.

What is knitr R Markdown?

R Markdown is a variant of Markdown that has embedded R code chunks, to be used with knitr to make it easy to create reproducible web-based reports. The Markdown syntax has some enhancements (see the R Markdown page); for example, you can include LaTeX equations (see Equations in R Markdown).


1 Answers

To change from .Rpres to .Rmd you need to change file extension (easy) and the front matter of the markdown document (slightly more involved).

A .Rpres file places the front matter on the first slide:

Untitled
=============================
author: Your Name Here
date: 4 July, 2015

while a .Rmd document places the front matter in a special block:

---
title: "Untitled"
author: "Your Name Here"
date: "04 July, 2015"
output: ioslides_presentation
---

The rest of your presentation code remains in rmarkdown, and should require minimal work to convert.

Some exceptions that I can think of immediately include

  • ioslides/slidify don't support columns via *** (a real shame, as this is so convenient)
  • Rpres doesn't support citations and a bibliography (also a shame)

Additionally, when converting you will need to look for any speciall CSS or other directives that are only supported by one framework.

like image 108
Brian G. Peterson Avatar answered Oct 24 '22 16:10

Brian G. Peterson