【问题标题】:Specifying variables in cor.matrix在 cor.matrix 中指定变量
【发布时间】:2016-08-12 22:29:11
【问题描述】:

尝试使用Deducercor.matrix 创建要在ggcorplot 中使用的相关矩阵。

尝试运行一个简单的示例。只有在数据中明确指定变量名才有效:

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

那么有没有办法告诉variables 使用data 中的所有列而不明确指定它们?

【问题讨论】:

    标签: r deducer


    【解决方案1】:

    函数的第一个参数是variables =,它是必需的,但你没有指定(你有data =)。试试

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

    【讨论】:

    • @dan 这解决了你的问题吗?如果是这样,请考虑投票/接受答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    • 2011-07-28
    • 1970-01-01
    相关资源
    最近更新 更多