- ggplot2双y轴图
[color=rgba(0, 0, 0, 0.75)]t2 <- read.table('C:/Users/19737/Desktop/iqeq.txt')n <- 1:31p1 <- ggplot(t2, aes(x = n))p1 <- p1 + geom_point(aes(y=iq,colour='iq'))p1 <- p1 + geom_point(aes(y=eq, colour = 'eq'))p1 <- p1 + scale_y_continuous(sec.axis = sec_axis(~.*1, name = 'eq'))p1 <- p1 + scale_colour_manual(values = c('blue', 'red'))p1 <- p1 + labs(y = 'iq',x = 'Number',colour = 'type')p1 <- p1 + theme(legend.position = c(0.8, 0.9))p1
[color=rgba(0, 0, 0, 0.75)]

2.pearson相关系数计算与检验
[color=rgba(0, 0, 0, 0.75)]> cor(t2,use = "everything",method = "pearson") iq eqiq 1.0000000 0.9183849eq 0.9183849 1.0000000> cor.test(t2$iq,t2$eq,method= "pearson") Pearson's product-moment correlationdata: t2$iq and t2$eqt = 12.499, df = 29, p-value = 3.347e-13alternative hypothesis: true correlation is not equal to 095 percent confidence interval: 0.8361430 0.9602424sample estimates: cor 0.9183849


雷达卡



京公网安备 11010802022788号







