0

我正在使用rmarkdownviaR-Studio并想heatmap通过heatmap.2. strCol当我通过选项更改列标签的角度时,我会在输出 PDF 文件NULL 之前打印一条消息。 附上一个最小的代码重现问题:heatmap

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

PDF看起来像

在此处输入图像描述

有没有办法NULL从 PDF 输出中删除它?

4

1 回答 1

2

尝试使用以下修改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 post Suppress one command's output in R

于 2016-05-05T06:14:47.507 回答