I have the following data.frame which I would like to plot with ggplot2:
df = data.frame(mean=c(1.96535,2.133604,1.99303,1.865004,2.181713,1.909511,2.047971,1.676599,2.143763,1.939875,1.816028,1.95465,2.153445,1.802517,2.141799,1.722428), sd=c(0.0595173,0.03884202,0.0570006,0.04934336,0.04008221,0.05108064,0.0463556,0.06272475,0.04321496,0.05283728,0.05894342,0.05160038,0.04679423,0.05305525,0.04626291,0.0573123), par=as.factor(c("p","p","m","m","p","p","m","m","m","m","p","p","m","m","p","p")), group=as.factor(c("iF","iF","iF","iF","iM","iM","iM","iM","RF","RF","RF","RF","RM","RM","RM","RM")), rep=c(1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2))
This is my code for doing that:
p
which produces this figure:
I would like to add this data.frame under the legend:
leg.df = data.frame(statistic = c("pp(par)","pp(g)","pp(s)","fc(p/m)"), value = c(0.96,0.94,0.78,1.5))
I followed this stackoverflow thread for inserting a table under the legend in a ggplot2 using this code:
g_legend
which produces exactly what I want:
The only problem is that I cannot get it to print everything to a file. I tried specifying pdf(
in front of the entire block of code and dev.off()
after it, but that doesn't seem to work. So I can only get it to print to the R screen.
So I guess I should be handling the legend part differently but I have no idea how.
Any suggestions?