r - R中data.farme中所有变量的相关性
问题描述
我知道输入一个 data.framecor
会自动给出一个相关矩阵(例如cor(mtcars)
)。
但我想知道为什么当我输入自己的 data.frame ( dat_w
) 时cor
会出现以下错误?
我有NA
并且Inf
已经使用了use = 'pairwise.complete.obs'
.
dat_w <- read.csv('https://raw.githubusercontent.com/izeh/n/master/w1.csv', stringsAsFactors = F)
cor(dat_w, use = 'pairwise.complete.obs')
# >Error : 'x' must be numeric
解决方案
因为您的第二列 ( gender
) 不是数字。尝试 :
cor(dat_w[-2], use = 'pairwise.complete.obs')
推荐阅读
- google-api - 无法为 Google Docs API 设置适当的范围
- minify - 有人可以指导我如何在我的反应应用程序(firebase)中使用 imagemin-webp 吗?
- jquery - 如何使用 POST 方法将 jquery 中的数据传递到 laravel 控制器
- nghttp2 - 断言“!inside_callback_”失败
- javascript - 无法通过 nodejs 中的 nodemailer 发送电子邮件
- dynamics-crm - 使用带有访问令牌的 REST API 在 Dynamic365 CRM 中获取联系人列表的问题
- sql-server - 不同Scheme中表的SQL关系
- sql-server - datediff 两列不同行 sql
- r - 如何增加 heatmap.2() 中颜色范围的最大值
- sql-server - 更新源表中的列后的 SQL Server 合并语句