编织+ RweaveHTML:cat 输出未出现在输出中
我对 Sweave + RweaveHTML 有问题
,我希望 cat 的输出最终出现在正在生成的 html 文件中。我有一个情况,它没有,我不明白为什么:(
test = function()
{
#bla bla;
cat("Result is...")
}
然后在 Rnw 文件中我尝试了所有这些:
<<echo=FALSE, results=html, include=TRUE>>=
test()
@
<<results=html, include=TRUE>>=
test()
@
<<results=html>>=
test()
@
<<>>=
test()
@
但我没有在生成的 HTML 文件中得到 cat 输出。 我很确定这应该有效...
我应该做什么才能将标准输出输出到最终的 html 文件有什么想法吗?
谢谢!
I have a problem with Sweave + RweaveHTML
I want the output of cat ends to up in the html file being generated. I have a case in which it does not and I can't figure out why :(
test = function()
{
#bla bla;
cat("Result is...")
}
And then in the Rnw file I tried all of these:
<<echo=FALSE, results=html, include=TRUE>>=
test()
@
<<results=html, include=TRUE>>=
test()
@
<<results=html>>=
test()
@
<<>>=
test()
@
But I don't get the cat output in the resulting HTML file.
I'm pretty sure this is supposed to work...
Any ideas of what I'm supposed to do to get the stdout ouput to the final html file?
Thx!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
RweaveHTML
驱动程序与RweaveLatex
驱动程序的工作方式不同,在创建输出时,每行代码的结果均使用通用函数 <代码>HTML。其他创建输出的方法不起作用。因此,要从函数内获取输出,我知道有两种方法;一种是返回一个由HTML
泛型处理的值,另一种是直接调用HTML
。以下test
函数的替换演示了这两种情况。也可以将
cat
替换为HTML
;那么你原来的功能就可以工作了。但这有点像黑客行为,可能会产生不可预见的后果;您可以在文档的开头放入一个(可能是隐藏的)Sweave 块。
The
RweaveHTML
driver works differently than theRweaveLatex
driver in that to create output, the result from every line of code is processed with the generic functionHTML
. Other ways of creating output don't work. So to get output from within a function, there are two ways I know of; one is to return a value to be processed by theHTML
generic, and the other is to callHTML
directly. The following replacement of yourtest
function demonstrates both.It's also possible to replace
cat
withHTML
; then your original function would work. But it's a bit of a hack and could have unforeseen consequences; you'd putin a (probably hidden) Sweave chunk at the beginning of the document.