I'd like to plot the correlations from variables B, C, D (y-axis) vs A (x-axis), to obtain a plot similar to this:
How can I obtain specific correlation trend lines and R values for each of the variables plotted on a log scaled y-axis? So far I have obtained the following:
A = c(3984,5307,3907, 3848, 4024, 6930, 6217, 6206, 5976, 4043)
B = c(18117, 16512, 17891, 17783, 12643, 12864, 10997, 12946, 12325, 12594)
C = c(9403, 9375, 7142, 6659, 8660, 9072, 7965, 8444, 6467, 6245)
D = c(443, 564, 541, 525, 503, 682, 563, 584, 639, 413)
data = data.frame(A, B, C, D)
data2<- melt(data, id.vars = 'A', variable.name = 'letter')
ggplot(data2, aes(A,value)) + geom_point(aes(colour = letter)) + scale_y_continuous(trans='sqrt') + stat_smooth(method=lm) + stat_cor(aes(color = letter), label.x = 3)
ggplot(data2, aes(A,value)) + geom_point(aes(colour = letter)) + stat_cor(method = "pearson", label.x = 4000, label.y = 1.9) + stat_smooth(method=lm) + facet_wrap(letter~ .)