2

I created a correlation plot:

library(nycflights13)
ggpairs(flights) +
  ggsave(filename = paste("overall_corr_plot.png"), path = paste(getwd(), "/images", sep = ""))

This gives me an error:

Error in `+.gg`(ggpairs(flights), ggsave(filename = paste("overall_corr_plot.png"),  :                                                        
  'ggmatrix' does not know how to add objects that do not have class 'theme' or 'labels'. Received object with class: 'NULL'
In addition: There were 15 warnings (use warnings() to see them)

It seems it's missing some data. Is it possible to fix this and if yes, how?

SomeDutchGuy
  • 2,249
  • 4
  • 16
  • 42

1 Answers1

3

You aren't adding ggsave to your plot, which is what the + denotes here. Just call ggsave after running your plot, it automatically saves the last plot sent to your graphics device.

ggpairs(flights)
ggsave(filename = paste("overall_corr_plot.png"), path = paste(getwd(), "/images", sep = ""))

Note that ggpairs on the entire flights data is going to be madness and you will have to drastically increase the cardinality_threshold, but that's not the issue here.

caldwellst
  • 5,719
  • 6
  • 22
  • Is it possible to first zoom? This seems to cut off some of the data that is exposed when I zoom on the plot in the output window doing it on a bigger frame with more variables. – SomeDutchGuy Mar 16 '20 at 11:58