我正在使用R中Psych包中的pairs.panel来创建漂亮的散点图和数据框中多个变量的相关性。
require(psych)
# plot correlation no weights
pairs.panels(iris[ ,1:3],
gap = 0,
pch = 21,
ellipses = TRUE,
show.points = TRUE,
smoother = TRUE,
rug = FALSE,
main = '~ Naive Correlations',
cor = TRUE
)
包的帮助表明加权可用于计算加权相关性...请参阅下面的尝试
# weighted correlations
pairs.panels(iris[ ,1:3],
gap = 0,
pch = 21,
ellipses = TRUE,
show.points = TRUE,
smoother = TRUE,
rug = FALSE,
main = '~ Weighted Correlations',
cor = TRUE,
wt = iris[ ,4]
)
此尝试在wt [,c(1:2)]中返回错误'错误:维度数不正确'。我不确定为什么我会收到这个错误,因为我认为指向一列权重会起作用 - 建议赞赏