2016-09-05 14 views
2

相関行列プロットに変数名と共に変数ラベルを含めたいと思います。相関行列プロットの変数ラベル

Rで行う方法はありますか? マイコード:

library(corrplot) 
corrplot(cor.mat, type="upper", order="hclust", 
     tl.col="black", tl.srt=45) 

ありがとうございます。

答えて

0

私のパッケージexpssを試すことができます。ソリューションは完璧ではありませんが、多くの場合私を助けます:

library(corrplot) 
library(expss) 

data(iris) 
iris2 = iris[,-5] # drop 'Species' - factor variable 

# apply labels 
var_lab(iris2$Sepal.Length) = "Sepal Length" 
var_lab(iris2$Sepal.Width) = "Sepal Width" 
var_lab(iris2$Petal.Length) = "Petal Length" 
var_lab(iris2$Petal.Width) = "Petal Width" 

# for each variables add variable name to label 
for (each in colnames(iris2)){ 
    var_lab(iris2[[each]]) = paste(each, var_lab(iris2[[each]])) 
} 

# replace names with labels and build correlation matrix 
cor.mat = cor(names2labels(iris2)) 

corrplot(cor.mat, type="upper", order="hclust", 
     tl.col="black", tl.srt=45) 
関連する問題