Filter Out the Cases from an Object in R Programming - filter() Function Last Updated : 15 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report filter() function in R Language is used to choose cases and filtering out the values based on the filtering expression. Syntax: filter(x, expr) Parameters: x: Object to be filtered expr: expression as a base for filtering Example 1: Python3 1== # R Program to filter cases # Loading library library(dplyr) # Create a data frame with missing data d <- data.frame( name = c("Abhi", "Bhavesh", "Chaman", "Dimri"), age = c(7, 5, 9, 16), ht = c(46, NA, NA, 69), school = c("yes", "yes", "no", "no") ) d # Finding rows with NA value filter(d, is.na(ht)) # Finding rows with no NA value filter(d, ! is.na(ht)) Output: name age ht school 1 Abhi 7 46 yes 2 Bhavesh 5 NA yes 3 Chaman 9 NA no 4 Dimri 16 69 no name age ht school 1 Bhavesh 5 NA yes 2 Chaman 9 NA no name age ht school 1 Abhi 7 46 yes 2 Dimri 16 69 no Example 2: Python3 1== # R Program to filter cases # Loading library library(dplyr) # Create a data frame d <- data.frame( name = c("Abhi", "Bhavesh", "Chaman", "Dimri"), age = c(7, 5, 9, 16), ht = c(46, NA, NA, 69), school = c("yes", "no", "yes", "no") ) d # Finding rows with school filter(d, school == "yes") # Finding rows with no school filter(d, school == "no") Output: name age ht school 1 Abhi 7 46 yes 2 Bhavesh 5 NA no 3 Chaman 9 NA yes 4 Dimri 16 69 no name age ht school 1 Abhi 7 46 yes 2 Chaman 9 NA yes name age ht school 1 Bhavesh 5 NA no 2 Dimri 16 69 no Comment More infoAdvertise with us Next Article Convert an Object to Data Frame in R Programming - as.data.frame() Function N nidhi_biet Follow Improve Article Tags : R Language R Object-Function Similar Reads Convert an Object to Data Frame in R Programming - as.data.frame() Function as.data.frame() function in R Programming Language is used to convert an object to data frame. These objects can be Vectors, Lists, Matrices, and Factors. Syntax: as.data.frame(object) Parameters:Â object: Vector, Matrix, factor, or data frameR - as.data.frame() Function ExampleExample 1: Basic exam 2 min read Checking if the Object is a Factor in R Programming - is.factor() Function is.factor() function in R Language is used to check if the object passed to the function is a Factor or not. It returns a boolean value as output. Syntax: is.factor(Object) Parameters: Object: Object to be checked Example 1: Python3 1== # Creating a vector x<-c("female", "male 1 min read Check if the Object is a Data Frame in R Programming - is.data.frame() Function is.data.frame() function in R Language is used to return TRUE if the specified data type is a data frame else return FALSE. R data.frame is a powerful data type, especially when processing table (.csv). It can store the data as row and columns according to the table. Syntax: is.data.frame(x) Paramet 1 min read Convert a Vector into Factor in R Programming - as.factor() Function as.factor() function in R Programming Language is used to convert the passed object(usually Vector) into a Factor. Syntax: as.factor(object) Parameters:Â Object: Vector to be convertedas.factor() Function in R ExampleExample 1: Convert a Factor in RR # Creating a vector x<-c("female", "male", "ma 1 min read Convert an Object into a Vector in R Programming - as.vector() Function as.vector() function in R Language is used to convert an object into a vector. Syntax: as.vector(x) Parameters: x: Object to be converted Example 1: Python3 1== # R program to convert an object to vector # Creating an array x <- array(c(2, 3, 4, 7, 2, 5), c(3, 2)) x # Calling as.vector() Function 1 min read Create Subsets of a Data frame in R Programming - subset() Function subset() function in R Programming Language is used to create subsets of a Data frame. This can also be used to drop columns from a data frame.Syntax: subset(df, expr)Parameters: df: Data frame usedexpr: Condition for subsetCreate Subsets of Data Frames in R Programming LanguageHere we will make sub 3 min read Like