I have a data frame created the following way.
library(ggplot2) x <- data.frame(letters[1:10],abs(rnorm(10)),abs(rnorm(10)),type=\"x\") y <- data.frame(le
There is an additional package ggpubr available now addressing exactly this issue with the stat_cor() function.
ggpubr
stat_cor()
library(tidyverse) library(ggpubr) ggplot(all, aes(val1, val2))+ geom_smooth(method = "lm") + geom_point() + facet_grid(~type) + stat_cor()