Here is my MWE code.
这是我的MWE代码。
\documentclass{beamer}
\begin{document}
<<setup, include=FALSE>>=
# smaller font size for chunks
opts_chunk$set(size = 'footnotesize')
options(width=60)
@
\begin{frame}[fragile]
\frametitle{Test1}
<<boring-random>>=
y <- c(5, 7, 15, 17, 17, 19)
Trt <- gl(n = 3, k = 2, length = 3 * 2, labels = paste("Trt",
1:3, sep = ""), ordered = FALSE)
Data <- data.frame(Trt, y)
Fit1 <- aov(formula = y ~ Trt, data = Data, contrasts = list(Trt = "contr.sum"))
ANOVA1 <- anova(Fit1)
Coeffs1 <- coefficients(Fit1)
@
\end{frame}
\end{document}
I'm struggling to keep the R chunk code within the Beamer frame. I wonder what is the efficient way to manage the R chunk codes such that they stay inside the Beamer frame. Thanks
我正在努力将R块代码保留在Beamer框架内。我想知道管理R块代码的有效方法是什么,以便它们保留在Beamer框架内。谢谢
1 个解决方案
#1
5
The best approach is to turn off the tidy
option by tidy=FALSE
, and manually break your lines.
最好的方法是通过tidy = FALSE关闭整洁选项,并手动断开你的线。
<<boring-random, tidy=FALSE>>=
y <- c(5, 7, 15, 17, 17, 19)
Trt <- gl(n = 3, k = 2, length = 3 * 2, labels = paste("Trt",
1:3, sep = ""), ordered = FALSE)
Data <- data.frame(Trt, y)
Fit1 <- aov(formula = y ~ Trt, data = Data,
contrasts = list(Trt = "contr.sum"))
ANOVA1 <- anova(Fit1)
Coeffs1 <- coefficients(Fit1)
@
This will always work. The other way is to set smaller width
in options()
(knitr FAQ 8), and you probably need to try a few times for an ideal width
. In your case, 60 is apparently too big.
这将始终有效。另一种方法是在options()(knitr FAQ 8)中设置较小的宽度,你可能需要尝试几次以获得理想的宽度。在你的情况下,60显然太大了。
#1
5
The best approach is to turn off the tidy
option by tidy=FALSE
, and manually break your lines.
最好的方法是通过tidy = FALSE关闭整洁选项,并手动断开你的线。
<<boring-random, tidy=FALSE>>=
y <- c(5, 7, 15, 17, 17, 19)
Trt <- gl(n = 3, k = 2, length = 3 * 2, labels = paste("Trt",
1:3, sep = ""), ordered = FALSE)
Data <- data.frame(Trt, y)
Fit1 <- aov(formula = y ~ Trt, data = Data,
contrasts = list(Trt = "contr.sum"))
ANOVA1 <- anova(Fit1)
Coeffs1 <- coefficients(Fit1)
@
This will always work. The other way is to set smaller width
in options()
(knitr FAQ 8), and you probably need to try a few times for an ideal width
. In your case, 60 is apparently too big.
这将始终有效。另一种方法是在options()(knitr FAQ 8)中设置较小的宽度,你可能需要尝试几次以获得理想的宽度。在你的情况下,60显然太大了。