【问题标题】:Correlation matrix correlations in R shown as "?" in the gridR 中的相关矩阵相关性显示为“?”在网格中
【发布时间】:2020-07-23 13:16:11
【问题描述】:

我想在给定“data1.new”数据集的情况下创建一个相关矩阵。 我知道“NA”值用问号表示。我已经使用“complete.obs”删除了 NA 值。

data1.new<-data1[4:11]
summary(data1.new)
cor(data1.new, use = "complete.obs")
library(corrplot)
forcorrplot <- cor(data1.new)
corrplot(forcorrplot, method="number",shade.col=NA, tl.col="black", tl.srt=45)

我的结果如下:

【问题讨论】:

  • 嗨,S.S,欢迎来到 Stack Overflow。请通过使用输出编辑您的帖子,至少向我们提供datadput(data)dput(data[1:10,]) 的样本。请参阅How to make a reproducible example 了解更多信息。

标签: r matrix na pearson-correlation


【解决方案1】:

问题是corcomplete.obs 没有分配给对象forcorrplot

library(corrplot)
data(mtcars)
mtcars[1:5, 2:5] <- NA
M <- cor(mtcars)
corrplot(M, method = 'number', shade.col=NA, tl.col="black", tl.srt=45)

现在检查

M <- cor(mtcars, use = "complete.obs")
corrplot(M, method = 'number', shade.col=NA, tl.col="black", tl.srt=45)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-12-07
    • 1970-01-01
    • 2019-08-30
    • 1970-01-01
    • 2019-07-28
    • 2013-06-15
    • 2015-11-20
    • 1970-01-01
    相关资源
    最近更新 更多