如何解决如何将 R Sweave 中用户定义函数的文本输出包装为 pdf
当通过 Sweave 编译为 pdf 时,我们无法让用户定义函数的输出换行文本,而是跑出页面并且不可读。下面给出了类似于用户定义函数之一的输出示例代码。
我们正在 Sweave 中寻找一种解决方案,我们可以在其中调用该函数并将输出包装在 pdf 的边距内。如果可能,我们希望避免编辑函数本身。
\documentclass{article}
\begin{document}
\SweaveOpts{concordance=TRUE}
<<>>=
long_output <- function(x,group){
var1 <- paste0(group,"_",x,".devcmn")
var2 <- paste0(group,".cmn")
resNames <- c(var1,var2)
class(resNames) <- "long_output"
return(resNames)
}
print.long_output <- function(x){
cat("The following variables (group summary,deviation) were added to the dataset:",x[1],x[2],'\n')
cat("See package documentation for detailed description of variables added.")
}
long_output("Variable","Grouping")
@
\end{document}
- Getting Sweave code chunks to stay inside page margins?
- How to keep code chunk within margins in Rmd when knitting to PDF
- In R markdown in RStudio,how can I prevent the source code from running off a pdf page?
- https://tex.stackexchange.com/questions/41471/getting-sweave-code-chunks-to-stay-inside-page-margins
- https://github.com/yihui/knitr-examples/blob/master/077-wrap-output.Rmd
- https://github.com/rstudio/rmarkdown/issues/646
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。