R——相關(guān)關(guān)系熱圖
> # 構(gòu)建相關(guān)關(guān)系矩陣
> library(psych)
> data.corr <- corr.test(rows, cols, method="pearson", adjust="fdr")
> data.r <- data.corr$r # 相關(guān)系數(shù)
> data.p <- data.corr$p # p值
>
> # 畫熱圖
> library(pheatmap)
> pheatmap(data.r, clustering_method="average")
R內(nèi)置函數(shù) cor() 可以用來(lái)計(jì)算相關(guān)系數(shù):cor(x, method = c("pearson", "kendall", "spearman"))肌割,如果數(shù)據(jù)有缺失值堪夭,用cor(x, method = "pearson", use = "complete.obs")。