如何获得数据的工作corrplot?
我正在尝试获取数据变量的Corrplot,这些变量是二进制,连续和分类变量的组合。但是,当我运行此代码时,它会不断给我错误。当我加载数据框时,称为DF2的错误是:Corrplot中的错误(DF2):矩阵不在[-1,1]!中。我该如何解决?
当我计算相关性时,我也会得到某些变量,即使它们是数字和整数值 1 。
附加了我的数据变量的示例,其中hh_code是用于标识的列: 2
如何我在r中获得了我的数据变量之间的相关性?谢谢!
I am trying to get the corrplot for my data variables which are a combination of binary, continuous and categorical variables. However, when I run this code, it keeps giving me errors. The error when i load my data frame, called df2, is: Error in corrplot(df2) : The matrix is not in [-1, 1]!. How can I solve this?
When I compute the correlation I also get that for certain variables, I only receive NA's, even though they are numeric and integer values 1.
Attached an example of my data variables, where hh_code is the column used for identification: 2
How can I get the correlation between variables for my data in R? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您有一个表格,而其他列则是数字的,则可以使用函数
ggally :: ggpairs
来获取有关这些变量之间关联的概述:由 preprex软件包(v2.0.0)
如果您需要更严格一些,则可以使用统计测试来获得列/变量之间的显着关系(如果其假设成立):
cor.test(x,y,method =“ pearson”)
t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.t.test(x,y)
cor.test(as.numeric(x),as.numeric(y),method =“ spearman”)
anova
anova (lm(y〜x))
If you have a table in which some columns are numeric and others are categorical, you can use the function
GGally::ggpairs
to get an overview about the associations between these variables:Created on 2022-05-17 by the reprex package (v2.0.0)
If you need a little bit more rigour, you can use statistical tests to get significant relationships between columns / variables (if their assumptions hold):
cor.test(x,y, method = "pearson")
t.test(x, y)
cor.test(as.numeric(x), as.numeric(y), method="spearman")
anova(lm(y ~ x))