根据列过滤数据帧行

时间:2017-03-22 10:55:15

标签: r dataframe

我有一个具有这种结构的数据帧Train_classifier:

Note.Reco  Reason.Reco  Suggestion.Reco  Contact
9          absent       tomorrow          yes
8          absent                         yes
8          present      today             no
5                       yesterday         no

我想从此数据框中删除“Note.Reco”和“Reason.Reco”列的空值所有行。

预期结果:

Note.Reco  Reason.Reco  Suggestion.Reco  Contact
    9          absent       tomorrow          yes
    8          absent                         yes
    8          present      today             no

我尝试使用此R代码:

Train <- Train_classifier[!(!is.na(Train_classifier$Reason.Reco) & Train_classifier$Reason.Reco==''), ]

我收到此错误消息:

Warning message:
In is.na(Train_classifier$Reason.Reco) :
  is.na() applied to non-(list or vector) of type 'NULL'

空结果数据框

有什么想法吗?

谢谢

1 个答案:

答案 0 :(得分:1)

function addItem() {

    //get file
    var inputFile = document.querySelector('#inputFile');
    var getFile = inputFile.files[0];

    //get info
    var title = document.getElementById('itemTitle').value;
    var desc = document.getElementById('itemDesc').value;

    //add
    locallp.put({
    _id: new Date().toISOString(),
    title: title,
    description: desc,
    _attachments: {
        "file": {
            content_type: getFile.type,
            data: getFile
        }
    } 
    }).then(function(){
      console.log("Added to the database");
        location.href = "menu.html";  
    }).catch(function(err){
       console.log(err);
    });
}