处理R中的缺失数据 [英] Handling missing data in R

查看:69
本文介绍了处理R中的缺失数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正面临一个荒唐的境地。为了解决数据丢失的问题,我使用了以下代码:

I'm facing a ridiculous situation. To tackle missing data issue, I used this code:

fixed_data <- fetch_data[-which(! complete.cases(train_sample)),]
train_index <- sample(1:nrow(fixed_data), size = .7*nrow(fixed_data))
train_sample <- fixed_data[train_index, ]
test_sample <- fixed_data[-train_index,]

然后我检查分段数据的行以确保没有缺少值,但仍然缺少值!

Then I check the rows of portioned data to make sure there's no missing value, but there's still missing value!

length(which(! complete.cases(fixed_data)))


推荐答案

我将代码更改为

fixed_data <- fetch_data[which(complete.cases(fetch_data)),]

它现在正在工作。多么愚蠢的错误!

And it's working now. What a silly mistake!

这篇关于处理R中的缺失数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆