pmtcars <- cor_pmat(mtcars) # 使用ggcorrplot包的cor_pmat()函数计算p值 P <- ggcorrplot(cor, method = "circle", # 使用圆形表示每个相关性,默认是方形 type = "upper", # 只显示上三角 lab = T, lab_size = 3, # 显示相关性标注,调整字体大小 p.mat = pmat, insig = "blank", # pmat...
plot(c(0:5), col = 'white') text(2,4, labels = 'font=1:正常字体(默认)', font = 1) text(3,3, labels = 'font=2:粗体字体',font = 2) text(4,2,labels = 'font=3:斜体字体',font = 3) text(5,1,labels = 'font=4:粗斜体字体',font=4) 1. 2. 3. 4. 5. 1.1 字体大小...
cor=round(cor(df$carat,df$price),2) p+stat_poly_eq(aes(label=paste("italic(r)~`=`~",cor,sep = "")),formula = y~x,parse=T,size=4) ggsave("tmp3.pdf",width = 8,height = 8,units = "cm")另外也可以使用ggpubr包的stat_cor()函数,添加相关系数以及p值...
#Scatter plots(sp)sp <- ggscatter(mtcars, x="wt", y="mpg",add="reg.line",#Add regressionlineconf.int= TRUE,#Add confidence intervalcolor ="cyl", palette ="jco",#Color by group cylshape ="cyl"#Change point shape by groups cyl)+ stat_cor(aes(color=cyl), label.x =3)#Add corr...
在R中,`stat_cor` 是 `ggplot2` 包中的一个函数,用于在图形上添加相关性统计信息。默认情况下,它可能会显示 Pearson 相关系数,但你可以通过设置 `method` 参数来计算...
library(psych)library(corrplot)cr <- cor(mydata)p <- cor.mtest(mydata, conf.level = .95)corrplot(cr, method = "color", col = colorRampPalette(c('navy','white','firebrick3'))(200), addCoef.col = "black",number.cex = 0.8,###添加系数及字体 tl.col = "black", tl.srt...
shape="cyl"# 按组"cyl"更改点的形状)+stat_cor(aes(color=cyl),label.x=3)# 添加相关系数 sp 图片.png 在一页上排列图片 要在一个页面上排列多个图片,我们将使用ggarrange()[在ggpubr中],它是对plot_grid()[在cowplot包中]函数的包装。 与标准函数plot_grid()相比,ggarange()可以在多个页面上排列多...
1 R基础包stats里的cor函数R代码如下: options(digits=2) library(RSTAT2D); data('d5.8.1.1') df <- d5.8.1.1[,-1] cov(df) cor(df) cor(df, method = "spearman") 运行结果如下: > cov(df) h dbh v cpro wd wpro tl tw lrt h 2.88 8.1 0.416 -6.8 -21.6 23.6 -114 -0.201 -2.22...
rm1<-cor(dt) rm1 3. 计算特征值及相应的特征向量 特征值与特征向量均为矩阵分解的结果。特征值表示标量部分,一般为某个主成分的方差,其相对比例可理解为方差解释度或贡献度 ;特征值从第一主成分会逐渐减小。 特征向量为对应主成分的线性转换向量(线性回归系数),特征向...