Remove rows conditionally

We can also use the conditions using subset() function

Syntax:

subset(dataframe,condition )

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(subset(data,age>21 ))


Output:

    name age
2 manoja  23
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:

...