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

Programming Exercises

Write an R program to access the second column of a data frame.

Easy

Problem Statement

Write an R program to access the second column of a data frame.

Sample Input

Data Frame: 
 Name Age Gender
1 Alice 25 Female
2 Bob 30 Male
3 Carol 22 Female

Sample Output

[1] 25 30 22

Limits

Time: 2s · Memory: 256 MB

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