Pandoc将Knitr Beamer的幻灯片移至Rmarkdown

时间:2016-09-12 14:56:34

标签: knitr r-markdown pandoc

在很久以前,我在R中使用knitr + beamer写了一大堆幻灯片。现在我重新审视了很多材料并将它们转换成RMarkdown幻灯片(我使用reveal.js,但这既不是在这里也不是那里)。虽然每个讲座花一个小时左右来做这件事是令人愉快的,因为它让我有时间在BrainDead上进行无意识的复制粘贴编辑,我觉得必须有更好的方法。我尝试使用pandoc来使其工作,虽然它会将编译好的.tex文件精美地转换为markdown,这意味着丢失所有代码等等。本质上,我想转换原始的.Rnw文件转到新的.Rmd文件,从LaTeX + Beamer转移到标准的RMarkdown。

这样做的想法,提示和技巧?我错过了一些令人眼花缭乱的事情吗?

这是一个示例.Rnw文件,从我的临时文件中删除了我过去尝试不同的东西。 temp.Rnw是文件名。

\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}

我已尝试过多种处理方法。

pandoc -s temp.Rnw -o temp.md显然不行。我将temp.Rnw更改为temp.tex以查看是否可行

pandoc -s temp.tex -o temp.text

这会产生

Variation in Estimates of Sample Properties

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

所以,某些地方的R代码已完全消失,而其他地方的R代码则非常不稳定。所有格式都消失了。

0 个答案:

没有答案