【问题标题】:Null output when printing heatmap.2 object in rmarkdown在 rmarkdown 中打印 heatmap.2 对象时为空输出
【发布时间】:2016-05-05 05:20:59
【问题描述】:

我通过R-Studio 使用rmarkdown 并希望通过heatmap.2 绘制heatmap。当我通过 strCol 选项更改列标签的角度时,我在输出 PDF 文件中的 heatmap 之前打印了 NULL 消息。
附上最小代码重现问题:

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

PDF看起来像

有没有办法从 PDF 输出中删除这个 NULL

【问题讨论】:

    标签: r heatmap r-markdown gplots


    【解决方案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

    【讨论】:

      猜你喜欢
      • 2021-04-02
      • 1970-01-01
      • 1970-01-01
      • 2020-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-03
      • 2022-01-09
      相关资源
      最近更新 更多