同じ長さの対称行列が 2 つあります (1 つは相関係数を含み、もう 1 つは p 値を含みます)。
upper.tri に相関係数が含まれ、lower.tri に関連する p 値が含まれるような行列を作成しようとしています。
あなたの行列correl
がpval
# 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)]