我正在寻找一种使用皮尔逊相关或类似方法来关联data.frame中的邻居行的方法。我想关联row1-row2,row3-row4等。相关性应该根据列进行配对。有没有办法在R
中做到这一点> head(BindTissueSerumSort)
020 045 080 082 084 086 088 090
hsa-miR-99b-5p.dataTissue 0.96980500 1.32387470 -1.32165937 -0.64061449 0.7512897 -0.1502014 -0.47235641 -0.2801984
hsa-miR-99b-5p.dataSerum -1.01659519 0.63873118 1.20920323 -0.02219251 -0.1986268 0.5351617 0.38003350 -0.1744776
hsa-miR-99a-5p.dataTissue -0.09451709 -2.70764352 0.20155679 0.56183644 -1.0409176 -0.1489536 0.21819883 0.3711749
hsa-miR-99a-5p.dataSerum -0.97297544 -0.10758543 -0.02442682 -0.21588054 1.8790067 -0.7815082 2.12159150 -0.3951215
hsa-miR-98-5p.dataTissue 0.69694927 -0.07233065 -0.88524941 -0.83712359 1.7260447 -0.7358599 0.06612543 0.4686154
hsa-miR-98-5p.dataSerum -1.17634730 0.59454306 1.07522464 -0.95907146 -1.2341767 0.7373701 -1.05066066 -0.7045416
答案 0 :(得分:0)
尝试
df <- t(BindTissueSerumSort)
idx <- seq(1, ncol(df), 2)
sapply(idx, function(x) cor(df[, x], df[, x+1]) )