且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在R中使用NA值组合删除行的高效方法

更新时间:2023-02-18 10:11:48

dat 成为数据框,并且 cols 列名称向量或列号码。然后你可以使用

Let dat be a data frame and cols a vector of column names or column numbers of interest. Then you can use

dat[!rowSums(is.na(dat[cols])), ]

排除所有行至少有一个 NA

to exclude all rows with at least one NA.