在字符向量中将它们取消分组后,如何删除数据集中的NA?
这是数据集:
Mno drugs
100173 9
100173 3
100173 NA
100173 NA
100463 18
100463 18
100463 1
100463 NA
100463 NA
100463 NA
10061 18
10061 9
10061 2
a <- is.na(progression_diab)
我需要这样的输出:
s.no Mno drug3
1 100173 9
2 100173 3
5 100463 18
6 100463 18
7 100463 1
11 10061 18
12 10061 9
13 10061 2
14 10061 3
16 101793 0
答案 0 :(得分:0)
假设progression_dab
是一个字符向量,就像下面的x
一样,您可以这样做:
x <- c("a", NA, "b")
na.omit(x)
## "a" "b"
或:
theNAs <- is.na(x) # the indices of the NAs
x[!theNAs] # remove theses indices to x
## "a" "b"