R Language Removing missing data from a vector


Example

First lets create a vector called Vector1:

set.seed(123)
Vector1 <- rnorm(20)

And add missing data to it:

set.seed(123)
Vector1[sample(1:length(Vector1), 5)] <- NA

Now we can use the is.na function to subset the Vector

Vector1 <- Vector1[!is.na(Vector1)]

Now the resulting vector will have removed the NAs of the original Vector1