2016-08-12 3 views
-1

Deducercor.matrixを使用して、ggcorplotで使用する相関行列を作成しようとしています。cor.matrixでの変数の指定

簡単な例を実行しようとしています。データ内の変数名を明示的に指定するだけで動作します:

cor.mat<-cor.matrix(variables=d(Sepal.Length,Sepal.Width,Petal.Length,Petal.Width), 
         data=iris[1:4],test=cor.test,method='p') 

ただし、提供されたデータのすべての列を簡単に使用したいと思います。

この:

cor.mat<-cor.matrix(data=iris[1:4],test=cor.test,method='p') 

がエラーをスローします。

Error in eval(expr, envir, enclos) : argument is missing, with no default 

この:

cor.mat<-cor.matrix(variables=d(as.name(paste(colnames(iris)[1:4]),collapse=",")), 
        data=iris[1:4],test=cor.test,method='p') 

Error in as.name(paste(colnames(iris)[1:4]), collapse = ",") : 
    unused argument (collapse = ",") 

ので、明示的に指定せずにdataのすべての列を使用するようにvariablesを伝えるためにどのような方法がありますそれら?

答えて

0

関数の最初の引数はvariables =ですが、これは必須ですが指定しなかった(data =)。

cor.mat <- cor.matrix(variables = iris[1:4], test = cor.test, method = 'p') 
ggcorplot(cor.mat, data=iris) 

enter image description here

+0

@dan試してみてくださいこれはあなたの問題を解決しましたか?もしそうなら、回答をアップ/アップすることを検討してください。 – dww

関連する問題