从数据框中选择任何变量不是NA的行[重复]

时间:2022-04-18 04:49:38

Possible Duplicate:
Removing empty rows of a data file in R

可能重复:删除R中数据文件的空行

Suppose I have a dataframe df

假设我有一个数据帧df

I would like to select the rows from it, where any of the variables in the row are not NA. That is to say I only want to exclude the rows in which all the variables are NA

我想从中选择行,其中行中的任何变量都不是NA。也就是说我只想排除所有变量都是NA的行

1 个解决方案

#1


12  

df[apply(!is.na(df), 1, any), ]

#1


12  

df[apply(!is.na(df), 1, any), ]