I’m starting to get familiar with ggplot2, and I really like it. I just found a very quick way to use several dataframes within the same plot, provided that the dataframes share columns names.
One obvious application is the production of graphs with the mean (obtained by
aggregate) superposed to the original raw data.
You can do this in ggplot2 simply with something along the lines of
dat.me <- aggregate(dat,list(NEST=dat$NEST,NRR=dat$NRR,MES=dat$MES),mean)
base <- ggplot(dat,aes(x=NRR,y=PROP,colour=MES))
base+geom_point() + geom_line(data=dat.me)
By changing the
data argument, you will recycle the
aes settings. This is really handy.
The result is
Now, of course, is someone knows a simpler way to do it, I’d like to know!