using the function "complete.cases"
for example, if you want to remove the NA in dataset ,
> x <- c(1, 2, NA, 4, NA, 5)
> y <- c("a", "b", NA, "d", NA, "f")
> good <- complete.cases(x, y)
> good
[1] TRUE TRUE FALSE TRUE FALSE TRUE
> x[good]
[1] 1 2 4 5
> y[good]
[1] "a" "b" "d" "f"
above is from coursera lecture R from Professor Peng
Interested in a career in data analysis? Our Data Analyst Certification Course will equip you with the tools and techniques you need to succeed.