我想绘制变量 B、C、D(y 轴)与 A(x 轴)的相关性,以获得与此类似的图:
如何获得绘制在对数刻度 y 轴上的每个变量的特定相关趋势线和 R 值?到目前为止,我已经获得了以下信息:
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~ .)