【发布时间】:2013-11-16 17:57:43
【问题描述】:
在我的 Sweave 文件中,我将多次重复相同的代码块:
<<tab.r,results=tex, echo=FALSE>>=
tableInstance <- getTable(first1,second)
latex(tableInstance,file = "",rowname=NULL,longtable=TRUE,dec=4,center='centering',caption="test", lines.page=4000)
@
\newpage
<<tab.r,results=tex, echo=FALSE>>=
tableInstance <- getTable(first2,second)
latex(tableInstance,file = "",rowname=NULL,longtable=TRUE,dec=4,center='centering',caption="test", lines.page=4000)
@
\newpage
<<tab.r,results=tex, echo=FALSE>>=
tableInstance <- getTable(first3,second)
latex(tableInstance,file = "",rowname=NULL,longtable=TRUE,dec=4,center='centering',caption="test", lines.page=4000)
@
\newpage
在这段代码之前,我会定义first1,first2,first3,second,例如:
<<tab.r,results=tex, echo=FALSE>>=
first1 <- "FirstCondition1"
first2 <- "FirstCondition2"
first3 <- "FirstCondition3"
second <- "SecondCondition"
@
我想知道的是如何在某种函数(R 或LaTeX)中获取上面的大量代码块,这样我就不必在我的文档中重复 10 次了?理想情况下,它应该是某种函数,其中参数为first1,first2,first3,second,并且不需要粘贴大量代码。
【问题讨论】:
标签: r automation latex knitr sweave