Remove rows with NA values

we can remove rows that contain NA values using na.omit() function from the given data frame.

Syntax:

na.omit(dataframe)

Example:

R




# create a dataframe
data=data.frame(name=c("manoj","manoja","manoji","mano","manooj"),
                age=c(21,23,21,10,22))
  
# display by removing age less than 21
print(na.omit(data))


Output:

    name age
1  manoj  21
2 manoja  23
3 manoji  21
4   mano  10
5 manooj  22


How to Remove Rows in R DataFrame?

In this article, we will discuss how to remove rows from dataframe in the R programming language.

Similar Reads

Method 1: Remove Rows by Number

By using a particular row index number we can remove the rows....

Method 2: Remove rows conditionally

...

Method 3: Remove rows with NA values:

...