在r markdown中抑制控制台输出,但保留绘图 [英] suppress console output in r markdown, but keep plot

查看:324
本文介绍了在r markdown中抑制控制台输出,但保留绘图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下markdown块:

Hi I have the following markdown chunk:

```{r, echo=FALSE,warning=FALSE,message=FALSE,error=FALSE}
lapply(obj,function(x) plot(x,main="some plot") box() axis(1,at=seq(0,25,by=1))
```

输出是多个图.但是,在绘图下方的pdf文档中,我也得到了控制台消息.

The output is multiple plots. However I also get the console message in the pdf document underneath the plots.

<Plot 1> nice plot 1!
<Plot 2> nice plot 2!

-- nasty horrible console output
## [[1]] 
01.2882829 

## [[2]]
120.29393933

我尝试了echo/warning/error/message = FALSE,但是这些都不抑制控制台输出

I have tried echo/warning/error/message = FALSE, but neither of these suppress the console output

请帮助!

推荐答案

invisible中包装任何对象都会阻止自动print对其进行包装.

Wrapping any object in invisible will prevent automatically printing it.

您应该可以使用

invisible(lapply(obj,function(x) plot(x,main="some plot")))

但是echo=FALSE无效的事实表明可能还有其他情况发生.

However the fact that echo=FALSE doesn't work suggests that there might be something else going on.

这篇关于在r markdown中抑制控制台输出,但保留绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆