How to save an object through GGally in R

I have a pretty dumb question to ask everyone.

I use ggpairs under GGally to create a correlation matrix, and somehow I found that GGally did not provide a save function like ggplot2. The ggsave function does not work for an object without ggplot2. I tried using pdf or png, but they did not work. I am wondering if it is easy to save this picture in a local file? Thanks for your kind help.

+7
r ggplot2 ggally
source share
1 answer

Although the @CMichael comment is good (I did not know this, therefore +1), it is only applicable if you want to save a specific plot from a GGally-generated matrix. I believe that you want to keep the entire plot matrix - a necessity that I recently experienced. Therefore, you can use the standard R approach and save graphics by opening the corresponding graphics device (in the desired format), printing an object and closing the device, which effectively saves the graphics in the desired format.

# use pdf() instead of svg(), if you want PDF output svg("myPlotMatrix.svg", height = 7, width = 7) g <- ggpairs(...) print(g) dev.off() 
+12
source share

All Articles