Is Not NA in Vector

Here we can use this filter to get the values excluding NA values.

Syntax:

vector[!is.na(vector)]

where, vector is the input vector

Example:

R




# create a vector
vector1 = c(1, 2, 3, NA, 34, 56, 78, NA, NA, 34, NA)
  
# display vector
print(vector1)
  
# remove NA values using Not NA function
print(vector1[!is.na(vector1)])


Output:

[1]  1  2  3 NA 34 56 78 NA NA 34 NA
[1]  1  2  3 34 56 78 34

How to Use “Is Not NA” in R?

In this article, we will discuss how to use Is Not NA in R Programming Language.

NA is a value that is not a number. The is.na() method is used to check whether the given value is NA or not, we have to use the function for this. Inorder to use is NOT  NA, then we have to add the “!” operator to the is.na() function

Syntax:

!is.na(data)

where, data can be a vector/list, etc

Similar Reads

Is Not NA in Vector

Here we can use this filter to get the values excluding NA values....

Is Not NA in dataframe in a single column

...

Is Not NA in dataframe in multiple columns

If we want to exclude NA values in dataframe columns, then we can use the dataframe similarly to the vector....

Remove all NA

...