1

Ages ago, I wrote a boatload of slides using knitr + beamer in R. Now I'm revisiting a lot of the material and converting them into RMarkdown slides (I use reveal.js, but that is neither here nor there). While taking an hour or so per lecture to do this is delightful, as it gives me time to catchup on BrainDead while I do the mindless copy-paste-edit, I feel that there has to be a better way. I tried futzing with pandoc to get it to work, and while it would convert the compiled .tex files beautifully to markdown, that means losing all of the code, etc. Essentially, I'd like to convert the original .Rnw files over to new .Rmd files, moving from LaTeX+Beamer to standard RMarkdown.

Thoughts, tips, techniques to do so? Have I missed something blindingly obvious?

Here's a sample .Rnw file gakked from my temp file that I'd futz with to try out different things in the past. temp.Rnw was the filename.

\documentclass{beamer}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Lecture 6 - Some Lecture
%%%   
%%%
%%% Last Modified 9/7/2012
%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{tikz}
\usetikzlibrary{arrows}


%%%%%load in code chunks, and run some preperatory code
<<set-options, echo=FALSE, cache=FALSE>>=
opts_chunk$set(fig.align = "center")
opts_chunk$set(out.height="0.6\\textwidth")
opts_chunk$set(out.width="0.6\\textwidth")
@

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\center \huge Variation in Estimates of Sample Properties
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%
  \begin{frame}
<<agraph, echo=FALSE>>=
library(ggplot2)
qplot(mpg, cyl, data=mtcars)
@
\end{frame}


\end{document}

I've tried a number of ways of processing this.

pandoc -s temp.Rnw -o temp.md is an obvious no-go. I changed temp.Rnw to temp.tex to see if that would work

pandoc -s temp.tex -o temp.text

This produces

Variation in Estimates of Sample Properties

&lt;&lt;agraph, echo=FALSE&gt;&gt;= library(ggplot2) qplot(mpg, cyl,
data=mtcars) @

So, the R code in some places is gone entirely, and others it's very wonky. All formatting is gone.

5
  • Please add what you have so far: An example of an TEX file and how you convert it to markdown. Then we can see what to do about the chunks.
    – CL.
    Commented Sep 12, 2016 at 18:52
  • Sample .Rnw code added.
    – jebyrnes
    Commented Sep 13, 2016 at 18:04
  • Edited to include pandoc code.
    – jebyrnes
    Commented Sep 14, 2016 at 13:00
  • 1
    Thank you for the updates. However, I still don't quite see how you are able to convert the knitted TEX file to a markdown presentation. If I knit your example and use pandoc to convert the TEX to MD, this doesn't look at all like a presentation (it's just a line of text with an image below).
    – CL.
    Commented Sep 14, 2016 at 18:31
  • Exactly. I want to convert the unknitted file.
    – jebyrnes
    Commented Sep 16, 2016 at 20:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.