删除整个data.frame

时间:2019-06-05 17:59:22

标签: r

我正在为计量经济学作业做某些统计测试。该数据库具有879个变量,因此我决定仅测试其中两个变量之间的相关性。在创建新的data.frame时,我在第一列中看到一些行为空(无答案),但是在另一列中却显示了一些结果(错误的行)。如何删除两列的这些空行,所以列的顺序没有变化。

click for the image: for example 5th row has no value for the 1st column, and the 2nd gives a wrong answer by default

我尝试了此功能:

该数据在法语aidsichef中被调用,包含2列mydata.aidsichef和mydata.tchefnb。这是因为我从mydata data.frame中提取了它们。我已经尝试过重命名列,但是在这种情况下,R向我显示错误“未定义的列”。这是我尝试过的:

> aidsichef<-aidsichef[!apply(aidsichef$mydata.aidchef=="")]
Error in match.fun(FUN) : argument "FUN" is missing, with no default

我希望您能帮助我删除包含“”的整行,不仅是空单元格,否则第二列仍将包含假值。

0 个答案:

没有答案