开发者

Sweave how can I write R code inside the latex table environment?

开发者 https://www.devze.com 2023-03-11 21:43 出处:网络
I am working on Sweave now, when I want to use R code to describe one variable in the latex table. It turns out that Sweave cannot read these R codes, the output is not the variable, instead, the ou

I am working on Sweave now, when I want to use R code to describe one variable in the latex table.

It turns out that Sweave cannot read these R codes, the output is not the variable, instead, the output is the text form of all the c开发者_开发问答ode I write


You may want \Sexpr{R expression}; for example, this Sweave snippet

<<echo=FALSE>>=
z <- exp(pi)
@

\begin{tabular}{cc}
  a & \Sexpr{z} \\
  b & \Sexpr{round(z,3)}  \\
\end{tabular}

becomes this when Sweaved (Swoven?)

\begin{tabular}{cc}
  a & 23.1406926327793 \\
  b & 23.141  \\
\end{tabular}
0

精彩评论

暂无评论...
验证码 换一张
取 消