Community and GGPLOT2's Fans:
Sorry for this very basic question, I am new to R and new to ggplot2
I have the following toy code to use an example of what I am trying to achieve:
library ("lattice")
library ("latticeExtra")
data (iris)
xyplot(Sepal.Width ~ Sepal.Length | Species, data = iris, panel = function(x, y, ...) {
panel.xyplot(x, y, ...)
panel.lmlineq(x, y, adj = c(1,0),
lty = 1,col.text='red', pos= 4,
col.line = "blue", digits = 1,r.squared =TRUE)
panel.text(7, 4, round(cor(x, y),3), font=2, adj=c(0.5,-0.6))
panel.text(7, 4, round(cor.test(x,y)$p.value, 3), font=1, adj=c(0.5,0.6))},
xlab = "Sepal.Length", ylab = "Sepal_Width")
This codes generates an image (that I can't post), but you'll be able to see if you use the code.
So, as you can see, I have a df with levels (Species) that I'd like to plot (all at the same time) showing their regression line with the Rsquared and also printing their cor and cor.test outputs. Preferably, in an aesthetically pleasing manner.
Has anyone tried to do something similiar? Is there an efficient way to do it?
Many thanks, any help will be much appreciated