我正在 R 中创建一个情节,使用:
plot(IQ, isAtheist)
abline(lm(isAtheist~IQ))
智商是
numeric
和 isAtheist
是 boolean 值,具有值 TRUE
或 FALSE
.我试着写:
cor(IQ, isAtheist)
但它给了我一个错误:
Error in cor(IQ, isAtheist) : 'x' must be numeric
如何确定这两个变量之间的相关性?
最佳答案
我真的不知道你想如何解释这种情况下的相关性,但你可以试试 cor(IQ, as.numeric(isAtheist))
.
在这种情况下,TRUE 将为 1,FALSE 将为 0。
关于r - 数字变量和 boolean 变量之间的相关性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12993195/