在R中找到二进制变量之间的相关性时错误?
我有一个变量(10)为二进制/因子变量的列表。例如,有特定副作用的人与没有的人。我想找到这些变量之间的相关性。一个变量是否与另一个变量相关/相关。我无法在R中使用COR函数,因为这仅处理连续/定量数据。因此,我使用的是四函数。
correlation_data <- Toxicity %>% dplyr::select('variable1', 'variable2', 'variable3', 'variable4', etc....) %>% na.omit()
correlation_data [] <- lapply(correlation_data, factor)
install.packages("psych")
library(psych)
tetrachoric(correlation_data)
但是,我遇到了一个错误:
Error in t(x) - mx : non-numeric argument to binary operator
我不确定这意味着什么?如何克服此错误?
I have a list of variables (10) that are binary/factor variables. E.g. people who got a particular side effect vs people who did not. I want to find the correlation between these variables. Whether one variable is related/correlated to another. I can't use the cor function in R since this only deals with continuous/quantitative data. So I am using the tetrachoric function.
correlation_data <- Toxicity %>% dplyr::select('variable1', 'variable2', 'variable3', 'variable4', etc....) %>% na.omit()
correlation_data [] <- lapply(correlation_data, factor)
install.packages("psych")
library(psych)
tetrachoric(correlation_data)
However, I get an error saying:
Error in t(x) - mx : non-numeric argument to binary operator
I am not sure what this means? How do I overcome this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
数据必须是数字(在这种情况下为二进制)。您可以看到,如果数据是数字起作用的,但是如果它们是因素,则不会:
在2022-05-10上由 reprex软件包(v2.0.1)
The data have to be numeric (and binary in this case). You can see that if the data are numeric it works, but if they are factors it does not:
Created on 2022-05-10 by the reprex package (v2.0.1)