4

同じ長さの対称行列が 2 つあります (1 つは相関係数を含み、もう 1 つは p 値を含みます)。

upper.tri に相関係数が含まれ、lower.tri に関連する p 値が含まれるような行列を作成しようとしています。

4

1 に答える 1

11

あなたの行列correlpval

# create a new matrix that is the pvalues
new <- pval
# not sure what you want the diagonal to be, lets make it NA
diag(new) <- NA
# replace the upper triangle of this new matrix with the 
# upper triangle of the correlation matrix
new[upper.tri(new)] <- correl[upper.tri(correl)]
于 2012-10-29T04:12:29.697 に答える