I took the ggplot2 book, but I'm struggling to figure out how the data is saved through the layers.
For example, let's take a dataset and calculate the average for each X:
thePlot = ggplot( myDF , aes_string( x = "IndepentVar" , y = "DependentVar" ) ) thePlot = thePlot + stat_summary( fun.y = mean , geom = "point" )
How do I access summary statistics at the next level? For example, let's say I want to build a smooth line over a dataset. This seems to work:
thePlot = thePlot + stat_smooth( aes( group = 1 ) , method = "lm" , geom = "smooth" , se = FALSE )
But let's say I want to further ignore the specific value of X when creating the string? How to access a generic dataset to express a specific X exception?
More generally, how is data tied to a stream through layers? Have I always limited myself to the latest statistics? Can I reference the source dataset?
source share