I'd like to make a data frame that contains the summarized data (Variables and correlation values) used to generate the ggplot
from GGally
above.
library(ggplot2)
library(GGally)
data(flea)
p <- ggpairs(flea, columns = 2:4)
p.2.df <- ggplot_build(p)
Error in UseMethod("ggplot_build") :
no applicable method for 'ggplot_build' applied to an object of class "c('gg', 'ggmatrix')"
But unfortunately, the ggplot_build
doesn't work.
Please any help with it?
You can get the data as a list of data frames, one from each sub-plot by doing:
so far example, the data frame for the first plot (a density curve) starts:
and the first correlation label is :
Created on 2022-04-14 by the reprex package (v2.0.1)