Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个数据框,其中有一些带有 NA 条目的行,我想找到该行的索引和条目为 NA 的列。我正在以嵌套的方式循环来做到这一点,这需要太长时间。有更快的方法吗?谢谢。
set.seed(123) dfrm <- data.frame(a=sample(c(1:5, NA), 25,T), b=sample(c(letters,NA), 25,rep=T) which(is.na(dfrm), arr.ind=TRUE) row col [1,] 4 1 [2,] 5 1 [3,] 8 1 [4,] 11 1 [5,] 16 1 [6,] 20 1 [7,] 21 1 [8,] 24 1 [9,] 6 2