0

I'm using rmarkdown via R-Studio and want to plot a heatmap by the heatmap.2. When I change the angle of column labels via the strCol option I get a NULL message printed before the heatmap in the output PDF file.
Attached a minimal code reproduce the problem:

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

The PDF look like

enter image description here

Is there any way to remove this NULL from the PDF output?

t j
  • 7,026
  • 12
  • 46
  • 66
itamar kanter
  • 1,170
  • 3
  • 10
  • 25

1 Answers1

2

Try the following modification using capture.output. This did not print NULL for me.

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

There may be a better way with some option to heatmap.2 but I didn't see it in the documentation. This was based off of the following SO post Suppress one command's output in R.

Community
  • 1
  • 1
steveb
  • 5,382
  • 2
  • 27
  • 36