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
Is there any way to remove this NULL
from the PDF output?
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.