![Beamer 中带有 knitr 的 R 函数的参数](https://linux22.com/image/280328/Beamer%20%E4%B8%AD%E5%B8%A6%E6%9C%89%20knitr%20%E7%9A%84%20R%20%E5%87%BD%E6%95%B0%E7%9A%84%E5%8F%82%E6%95%B0.png)
我正在使用helpExtract.R
函数(可以从这里)使用R
来获取函数的参数。我的 ( ) MWE 是Beamer
knitr
.Rnw
\documentclass{beamer}
\usepackage{ragged2e} %new code
\usetheme{default}
\addtobeamertemplate{block begin}{}{\justifying} %new code
\addtobeamertemplate{knitrout begin}{}{\justifying} %new code
\addtobeamertemplate{alltt begin}{}{\justifying} %new code
<< label = setup, include = FALSE>>=
opts_chunk$set(size = 'footnotesize')
options(replace.assign = TRUE, width = 60)
@
\begin{document}
\begin{frame}[fragile]{Linear Model}
\begin{block}{lm}
<< label=lm-args, echo=FALSE, comment=NA>>=
str(args(lm))
@
\end{block}
\end{frame}
\begin{frame}[fragile]{Linear Model}
\begin{block}{lm function with testHelpExtract}
<< label = helpExtract-fn, echo = FALSE >>=
library(devtools)
source("helpExtract.R")
@
\Sexpr{knit_child(textConnection(helpExtract(lm, section="Usage", type = "s_code")), options = list(tidy = TRUE, echo=TRUE, eval = FALSE))}
\end{block}
\end{frame}
\begin{frame}[fragile]{Linear Model}
\begin{block}{lm function with testHelpExtract}
\Sexpr{knit_child(textConnection(helpExtract(lm, section="Arguments", type = "s_code")[1:15]), options = list(tidy = FALSE, echo=TRUE, eval = FALSE))}
\end{block}
\end{frame}
\begin{frame}[fragile]{Linear Model}
\begin{block}{lm function with testHelpExtract}
\Sexpr{knit_child(textConnection(helpExtract(lm, section="Arguments", type = "s_code")[16:25]), options = list(tidy = FALSE, echo=TRUE, eval = FALSE))}
\end{block}
\end{frame}
\end{document}
我对这个 MWE 有几个疑问。
问题
- 无法对齐块中的文本。
即使收到输出,仍收到此错误消息:错误消息
解析错误(文本 = 代码)::1:14:意外符号 1:公式:对象 ^
任何帮助解决这些问题的帮助都将不胜感激。谢谢