有沒有更好的方法來迭代給定數據集的一組參數?顯然,我試圖得到一個相關係數表:列是「CI,CVP,平均PAP,平均SAP」,行是「ALAT,ASAT,GGT,Bili,LDH,FBG」。對於每個組合,我想要得到相關係數和顯着性水平(p = ...)。 下面你看到「困難的方式」。但是,有沒有更優雅的方式,可能有可打印的表格?如何迭代通過參數進行分析
attach(Liver)
cor.test(CI, ALAT, method = "spearman")
cor.test(CI, ASAT, method = "spearman")
cor.test(CI, GGT, method = "spearman")
cor.test(CI, Bili, method = "spearman")
cor.test(CI, LDH, method = "spearman")
cor.test(CI, FBG, method = "spearman")
cor.test(CVP, ALAT, method = "spearman")
cor.test(CVP, ASAT, method = "spearman")
cor.test(CVP, GGT, method = "spearman")
cor.test(CVP, Bili, method = "spearman")
cor.test(CVP, LDH, method = "spearman")
cor.test(CVP, FBG, method = "spearman")
cor.test(meanPAP, ALAT, method = "spearman")
cor.test(meanPAP, ASAT, method = "spearman")
cor.test(meanPAP, GGT, method = "spearman")
cor.test(meanPAP, Bili, method = "spearman")
cor.test(meanPAP, LDH, method = "spearman")
cor.test(meanPAP, FBG, method = "spearman")
cor.test(meanSAP, ALAT, method = "spearman")
cor.test(meanSAP, ASAT, method = "spearman")
cor.test(meanSAP, GGT, method = "spearman")
cor.test(meanSAP, Bili, method = "spearman")
cor.test(meanSAP, LDH, method = "spearman")
cor.test(meanSAP, FBG, method = "spearman")
detach("Liver")
「Hmisc」中還有'rcorr',它會爲您提供單獨的相關係數矩陣和p值。 – A5C1D2H2I1M1N2O1R2T1