gpt4 book ai didi

r - 如何自动防止 Sweave 中的 R 输入超出右边距?

转载 作者:行者123 更新时间:2023-12-01 10:56:01 25 4
gpt4 key购买 nike

是否可以让 Sweave 在多行上自动打印 R 输入?例如,

\documentclass{article}

\begin{document}
\SweaveOpts{concordance=TRUE}
\setkeys{Gin}{width=\textwidth}

<<fig=TRUE>>=
plot(LakeHuron, ylab="Level in feet", xlab="Year", main="Level of Lake Huron 1875–1972", lwd=2, las=1)
@

\end{document}

将打印 R 代码以进入(和超出)右边距。据我推断,

<<>>=
options(width=60)
@

只控制R输出。

最佳答案

使用 ,您可以尝试将参数 keep.source = FALSE 添加到您的代码块,但这仍然不能默认解决您的问题(在这个特定示例中没有)。

这是您当前使用的输出的一部分:

<<fig=TRUE>>=
plot(LakeHuron, ylab="Level in feet", xlab="Year", main="Level of Lake Huron 1875–1972", lwd=2, las=1)
@

enter image description here

如果我们添加 keep.source = FALSE

,这是输出的一部分
<<fig=TRUE, keep.source=FALSE>>=
plot(LakeHuron, ylab="Level in feet", xlab="Year", main="Level of Lake Huron 1875–1972", lwd=2, las=1)
@

enter image description here

而且,如果我们稍微作弊并手动重新排序参数,这里是输出的一部分。请注意,我已将有问题的标题放在最后一项:

<<fig=TRUE, keep.source=FALSE>>=
plot(LakeHuron, ylab="Level in feet", xlab="Year", lwd=2, las=1, main="Level of Lake Huron 1875-1972")
@

enter image description here

关于r - 如何自动防止 Sweave 中的 R 输入超出右边距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15096594/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com