Data Structures In R Programming — Part 1 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Data Structures In R Programming — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/40 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which data structure in R is used to store an ordered collection of elements?
Correct Answer: Option D — Vector
Detailed Academic Explanation:
Vector is the correct answer to “Which data structure in R is used to store an ordered collection of elements”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the matrix() function create in R?
Correct Answer: Option C — A two-dimensional array
Detailed Academic Explanation:
A two-dimensional array is the correct answer to “What does the matrix() function create in R”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In R, how do you create a list named my_list with three elements: 1, "hello", and TRUE?
Correct Answer: Option B — my_list = list(1, "hello", TRUE)
Detailed Academic Explanation:
my_list = list(1, "hello", TRUE) is the correct answer to “In R, how do you create a list named my_list with three elements: 1, "hello", and TRUE”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the primary data structure used for storing tabular data in R?
Correct Answer: Option C — Data Frame
Detailed Academic Explanation:
Data Frame is the correct answer to “What is the primary data structure used for storing tabular data in R”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How is a vector different from a list in R?
Correct Answer: Option D — Vectors can store elements of different types
Detailed Academic Explanation:
Vectors can store elements of different types is the correct answer to “How is a vector different from a list in R”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In R, how is a matrix initialized with values 1 to 9 arranged in three rows?
matrix(1:9, nrow = 3, ncol = 3) is the correct answer to “In R, how is a matrix initialized with values 1 to 9 arranged in three rows”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you create a factor in R named color with levels "red", "green", and "blue"?
factor(color = c("red", "green", "blue"), levels = c("red", "green", "blue")) is the correct answer to “How do you create a factor in R named color with levels "red", "green", and "blue"”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the data.frame() function in R?
Correct Answer: Option B — Create a data frame
Detailed Academic Explanation:
Create a data frame is the correct answer to “What is the purpose of the data.frame() function in R”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In R, how do you create a named list with elements "apple", "orange", and "banana"?
Correct Answer: Option D — list(elements = c("apple", "orange", "banana"))
Detailed Academic Explanation:
list(elements = c("apple", "orange", "banana")) is the correct answer to “In R, how do you create a named list with elements "apple", "orange", and "banana"”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct way to access the second element of a vector named my_vector in R?
Correct Answer: Option B — my_vector[2]
Detailed Academic Explanation:
my_vector[2] is the correct answer to “What is the correct way to access the second element of a vector named my_vector in R”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you check the structure of a data frame named my_data in R?
Correct Answer: Option B — str(my_data)
Detailed Academic Explanation:
str(my_data) is the correct answer to “How do you check the structure of a data frame named my_data in R”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In R, what is the purpose of the names() function?
Correct Answer: Option C — Assign names to the elements
Detailed Academic Explanation:
Assign names to the elements is the correct answer to “In R, what is the purpose of the names() function”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What function is used to convert a factor to a character vector in R?
Correct Answer: Option B — as.character()
Detailed Academic Explanation:
as.character() is the correct answer to “What function is used to convert a factor to a character vector in R”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How is a data frame column named Age selected in R?
Correct Answer: Option B — data[,"Age"]
Detailed Academic Explanation:
data[,"Age"] is the correct answer to “How is a data frame column named Age selected in R”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In R, how do you add a new column named Height to a data frame named my_data?
Correct Answer: Option A — my_data$Height <- c(160, 170, 155)
Detailed Academic Explanation:
my_data$Height <- c(160, 170, 155) is the correct answer to “In R, how do you add a new column named Height to a data frame named my_data”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you create a character vector with the elements "apple", "orange", and "banana" in R?
Correct Answer: Option A — char_vec <- c("apple", "orange", "banana")
Detailed Academic Explanation:
char_vec <- c("apple", "orange", "banana") is the correct answer to “How do you create a character vector with the elements "apple", "orange", and "banana" in R”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the str() function do in R?
Correct Answer: Option A — Display the structure of an object
Detailed Academic Explanation:
Display the structure of an object is the correct answer to “What does the str() function do in R”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In R, how do you create a data frame named my_df with columns Name and Age?
Correct Answer: Option A — my_df <- data.frame(Name = c("Alice", "Bob"), Age = c(25, 30))
Detailed Academic Explanation:
my_df <- data.frame(Name = c("Alice", "Bob"), Age = c(25, 30)) is the correct answer to “In R, how do you create a data frame named my_df with columns Name and Age”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of length(unique(c(1, 2, 3, 1, 2))) in R?
Correct Answer: Option A — 3
Detailed Academic Explanation:
3 is the correct answer to “What is the result of length(unique(c(1, 2, 3, 1, 2))) in R”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In R, how is a factor converted to a numeric vector using the as.numeric() function?
Correct Answer: Option C — numeric(factor_vector)
Detailed Academic Explanation:
numeric(factor_vector) is the correct answer to “In R, how is a factor converted to a numeric vector using the as.numeric() function”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you extract the first row of a data frame named my_data in R?
Correct Answer: Option A — my_data[1, ]
Detailed Academic Explanation:
my_data[1, ] is the correct answer to “How do you extract the first row of a data frame named my_data in R”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In R, what is the purpose of the table() function?
Correct Answer: Option A — Create a contingency table from factors
Detailed Academic Explanation:
Create a contingency table from factors is the correct answer to “In R, what is the purpose of the table() function”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you remove a column named Income from a data frame named my_data in R?
Correct Answer: Option B — my_data$Income <- NULL
Detailed Academic Explanation:
my_data$Income <- NULL is the correct answer to “How do you remove a column named Income from a data frame named my_data in R”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In R, what does the unlist() function do?
Correct Answer: Option A — Converts a list to a vector
Detailed Academic Explanation:
Converts a list to a vector is the correct answer to “In R, what does the unlist() function do”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How is a character string converted to a numeric vector in R using the as.numeric() function?
Correct Answer: Option A — as.numeric("123")
Detailed Academic Explanation:
as.numeric("123") is the correct answer to “How is a character string converted to a numeric vector in R using the as.numeric() function”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In R, what is the purpose of the subset() function?
Correct Answer: Option A — Create a subset of a data frame based on conditions
Detailed Academic Explanation:
Create a subset of a data frame based on conditions is the correct answer to “In R, what is the purpose of the subset() function”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you add a new row to a data frame named my_data with values "Alice" and 28 for columns Name and Age?
Correct Answer: Option B — my_data <- add_row(my_data, Name = "Alice", Age = 28)
Detailed Academic Explanation:
my_data <- add_row(my_data, Name = "Alice", Age = 28) is the correct answer to “How do you add a new row to a data frame named my_data with values "Alice" and 28 for columns Name and Age”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What function is used to concatenate two vectors in R?
Correct Answer: Option C — c()
Detailed Academic Explanation:
c() is the correct answer to “What function is used to concatenate two vectors in R”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In R, what does the slice() function do?
Correct Answer: Option A — Extracts specific rows from a data frame
Detailed Academic Explanation:
Extracts specific rows from a data frame is the correct answer to “In R, what does the slice() function do”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you create a named numeric vector with values 1, 2, and 3 named "one", "two", and "three" in R?
vec_named(c(1, 2, 3), c("one", "two", "three")) is the correct answer to “How do you create a named numeric vector with values 1, 2, and 3 named "one", "two", and "three" in R”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following code represents internal representation of a Date object?
Correct Answer: Option B — unclass(as.Date("1970-01-02"))
Detailed Academic Explanation:
unclass(as.Date("1970-01-02")) is the correct answer to “Which of the following code represents internal representation of a Date object”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following R code? > x <- matrix(1:6, 2, 3) > x[1, ]
Correct Answer: Option A — 1 3 5
Detailed Academic Explanation:
1 3 5 is the correct answer to “What will be the output of the following R code? > x <- matrix(1:6, 2, 3) > x[1, ]”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following extracts first four element from the following R vector? > x <- c("a", "b", "c", "c", "d", "a")
Correct Answer: Option B — x[1:4]
Detailed Academic Explanation:
x[1:4] is the correct answer to “Which of the following extracts first four element from the following R vector? > x <- c("a", "b", "c", "c", "d", "a")”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The . . . . . . . . function is used to generate summary statistics from the data frame within strata defined by a variable.
Correct Answer: Option C — group_by()
Detailed Academic Explanation:
group_by() is the correct answer to “The . . . . . . . . function is used to generate summary statistics from the data frame within strata defined by a variable.”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Main way to read the data back in (parsing it) using the function.
Correct Answer: Option D — dget()
Detailed Academic Explanation:
dget() is the correct answer to “Main way to read the data back in (parsing it) using the function.”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
If we want to save individual R objects to a file, we use the . . . . . . . . function.
Correct Answer: Option A — save()
Detailed Academic Explanation:
save() is the correct answer to “If we want to save individual R objects to a file, we use the . . . . . . . . function.”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
load() is used for . . . . . . . .
Correct Answer: Option A — reading
Detailed Academic Explanation:
reading is the correct answer to “load() is used for . . . . . . . .”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following R code? > x <- 1:4 > y <- 6:9 > z <- x + y > z
Correct Answer: Option A — 7 9 11 13
Detailed Academic Explanation:
7 9 11 13 is the correct answer to “What will be the output of the following R code? > x <- 1:4 > y <- 6:9 > z <- x + y > z”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following extracts first element from the following R list? > x <- list(foo = 1:4, bar = 0.6)
Correct Answer: Option A — x[[1]]
Detailed Academic Explanation:
x[[1]] is the correct answer to “Which of the following extracts first element from the following R list? > x <- list(foo = 1:4, bar = 0.6)”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Columns can be arranged in descending order too by using the special . . . . . . . . operator.
Correct Answer: Option B — desc()
Detailed Academic Explanation:
desc() is the correct answer to “Columns can be arranged in descending order too by using the special . . . . . . . . operator.”. This question is standard in competitive examination syllabi for Data Structures In R Programming.
💡Key Conceptual Anchor:Data Structures In R Programming
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.