2016-05-05 28 views
0

我使用通过R-Studio并想通过heatmap.2绘制heatmap。当通过strCol选项更改列标签的角度时,我会在输出PDF文件的heatmap之前打印一条NULL消息。
附加最小代码重现该问题:当在rmarkdown中打印heatmap.2对象时为空输出

{r, message=FALSE,warning=FALSE, echo=FALSE} 
require(gplots) 
data(mtcars) 
x <- as.matrix(mtcars) 
heatmap.2(x,srtCol=0) 

的PDF看起来像

enter image description here

有没有办法从PDF输出删除此NULL

回答

1

使用capture.output尝试以下修改。这并没有为我打印NULL

```{r, message=FALSE,warning=FALSE, echo=FALSE} 
require(gplots) 
data(mtcars) 
x <- as.matrix(mtcars) 
res <- capture.output(heatmap.2(x,srtCol=0)) 
``` 

可能有一些选项heatmap.2一个更好的方式,但我没有看到它的文档。这是基于以下SO帖子Suppress one command's output in R