Write an R program to access the second column of a data frame.
EasyProblem 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)
Input
Data Frame: Name Age Gender 1 Alice 25 Female 2 Bob 30 Male 3 Carol 22 Female
Expected Output
[1] 25 30 22