-1

Trying to use Deducer's cor.matrix to create a correlation matrix to be used in ggcorplot.

Trying to run a simple example. Only explicitly specifying the variable names in the data works:

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

But I'd like it to simple use all columns in the provided data.

This:

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

throws an error:

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

This:

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 = ",")

So is there any way to tell variables to use all columns in data without explicitly specifying them?

dan
  • 6,048
  • 10
  • 57
  • 125

1 Answers1

0

The first argument of the function is variables =, which is required but you did not specify (you had data =). Try

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

enter image description here

dww
  • 30,425
  • 5
  • 68
  • 111
  • @dan did this solve your issue? If so, please consider upvoting / accepting the answer. – dww Aug 16 '16 at 11:47