Handling missing data in R

送分小仙女□ 提交于 2019-12-12 04:59:05

问题


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)))

回答1:


I changed the code to

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

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



来源:https://stackoverflow.com/questions/36628341/handling-missing-data-in-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!