Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write an R program to filter rows in a data frame based on a specific condition.

Medium

Problem Statement

Write an R program to filter rows in a data frame based on a specific condition.

Sample Input

Data Frame: 
 Name Age
1 John 25
2 Alice 30
3 Bob 22
Condition: Age > 25

Sample Output

   Name Age
2 Alice  30

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
# Predefined structure data <- data.frame(Name = c("John", "Alice", "Bob"), Age = c(25, 30, 22)) filtered_data <- data[data$Age > 25, ] print(filtered_data)
Log in or sign up to run or submit your code.Log inSign up
Input
Data Frame: 
 Name Age
1 John 25
2 Alice 30
3 Bob 22
Condition: Age > 25
Expected Output
   Name Age
2 Alice  30