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

问题描述

我的数据如下

  Name   Location  profits loss sales    address      revenue  stocks
   AA     London     20      30    2    Lheigts,20109   54       45
   BB     Boston     NA      NA   NA    KicK,30029     NA        NA
   CC     Mumbai     NA      2     NA   New, 10023     43        NA

我想要这样的输出,它将删除利润,亏损,销售,收入,库存完全缺失的情况.有什么想法吗?

I would like to have output like this which will delete cases for which profits, loss, sales, revenue, stocks are completely missing. Any ideas?

   Name   Location  profits loss sales    address      revenue  stocks
   AA     London     20      30    2    Lheigts,20109   54        45
   CC     Mumbai     NA      2     NA   New, 10023     43        NA

推荐答案

尝试

 df1[rowSums(!is.na(df1[c(3:5,7:8)]))!=0,]

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

07-30 12:36