Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save a graphic in R instead of visualizing it?

Tags:

r

heatmap

I a bit of code that produces a matrix. I then generate a heatmap from this matrix using the function:

heatmap(d)

However, I would like to be able to save this img directly and bypass displaying the graphic, so that I can incorporate this function into a unix-based workflow.

Can someone please show me the snippet of code required to save this image without displaying it on screen? Thanks!

like image 215
jake9115 Avatar asked Oct 19 '25 13:10

jake9115


1 Answers

Use jpeg(), png() or tiff() to create the file.

jpeg(file="filename.jpg")
heatmap(d)
dev.off()
like image 61
Hong Ooi Avatar answered Oct 22 '25 03:10

Hong Ooi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!