抑制热图的绘图

时间:2014-11-11 03:21:05

标签: r

如何在heatmap包中隐藏stats的情节?

x  <- as.matrix(mtcars)
hv <- heatmap(x)
hv

我希望在不调用图形设备的情况下获取hv

1 个答案:

答案 0 :(得分:0)

可能不是最好的主意,但这是一种方法:

x  <- as.matrix(mtcars)
hv <- heatmap(x)
hv

suppress_plot <- function(...) {
    tdir <- tempdir()
    png(file.path(tdir, "out.png"))
    out <- eval(substitute(...())[[1]])
    dev.off()
    out
}

suppress_plot(heatmap(x))