且构网

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

删除具有nan值的行

更新时间:2023-01-17 19:41:04

函数complete.cases会告诉您所需行的位置:

The function complete.cases will tell you where the rows are that you need:

data <- matrix(c(1,2,3,4,5,6,NaN,5,9,NaN,23,9), ncol=2)
data[complete.cases(data), ]

     [,1] [,2]
[1,]    2    5
[2,]    3    9
[3,]    5   23
[4,]    6    9