问题描述
当通过 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 (将#修改为@)