Data Manipulation With Dplyr — Part 1 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Data Manipulation With Dplyr — 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
In dplyr, what function is used to select specific columns from a data frame?
Correct Answer: Option C — select()
Detailed Academic Explanation:
select() is the correct answer to “In dplyr, what function is used to select specific columns from a data frame”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you filter rows in a dplyr data frame based on a specific condition using filter()?
Correct Answer: Option D — filter()
Detailed Academic Explanation:
filter() is the correct answer to “How do you filter rows in a dplyr data frame based on a specific condition using filter()”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In dplyr, what does the arrange() function do?
Correct Answer: Option C — Orders the rows based on a specific column
Detailed Academic Explanation:
Orders the rows based on a specific column is the correct answer to “In dplyr, what does the arrange() function do”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What function is used to create a new variable in a dplyr data frame based on existing variables?
Correct Answer: Option B — mutate()
Detailed Academic Explanation:
mutate() is the correct answer to “What function is used to create a new variable in a dplyr data frame based on existing variables”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you perform a group-wise summary operation using dplyr's group_by() and summarize() functions?
Correct Answer: Option D — summarize()
Detailed Academic Explanation:
summarize() is the correct answer to “How do you perform a group-wise summary operation using dplyr's group_by() and summarize() functions”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the distinct() function in dplyr?
Correct Answer: Option B — Removes duplicate rows from a data frame
Detailed Academic Explanation:
Removes duplicate rows from a data frame is the correct answer to “What is the purpose of the distinct() function in dplyr”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In dplyr, what does the mutate() function do?
Correct Answer: Option B — Creates a new variable based on existing ones
Detailed Academic Explanation:
Creates a new variable based on existing ones is the correct answer to “In dplyr, what does the mutate() function do”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you join two data frames based on a common column using dplyr's left_join()?
Correct Answer: Option C — left_join()
Detailed Academic Explanation:
left_join() is the correct answer to “How do you join two data frames based on a common column using dplyr's left_join()”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In dplyr, what is the purpose of the %>% operator (pipe operator)?
Correct Answer: Option B — Chains together a sequence of operations
Detailed Academic Explanation:
Chains together a sequence of operations is the correct answer to “In dplyr, what is the purpose of the %>% operator (pipe operator)”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the role of the summarize() function in dplyr?
Correct Answer: Option A — Applies a summary function to each group
Detailed Academic Explanation:
Applies a summary function to each group is the correct answer to “What is the role of the summarize() function in dplyr”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In dplyr, how do you calculate the mean of a numeric variable named score for each group using summarize()?
Correct Answer: Option D — summarize(mean_score = mean(score))
Detailed Academic Explanation:
summarize(mean_score = mean(score)) is the correct answer to “In dplyr, how do you calculate the mean of a numeric variable named score for each group using summarize()”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What function is used to rename columns in a dplyr data frame?
Correct Answer: Option B — rename()
Detailed Academic Explanation:
rename() is the correct answer to “What function is used to rename columns in a dplyr data frame”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In dplyr, how do you filter rows where a specific variable is not missing using filter()?
Correct Answer: Option D — filter(!is.na(variable))
Detailed Academic Explanation:
filter(!is.na(variable)) is the correct answer to “In dplyr, how do you filter rows where a specific variable is not missing using filter()”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you count the number of rows in a dplyr data frame?
Correct Answer: Option B — n()
Detailed Academic Explanation:
n() is the correct answer to “How do you count the number of rows in a dplyr data frame”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In dplyr, how do you select the top 5 rows based on a variable named value in descending order?
Correct Answer: Option A — top_n(5, value)
Detailed Academic Explanation:
top_n(5, value) is the correct answer to “In dplyr, how do you select the top 5 rows based on a variable named value in descending order”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the group_by() function do in dplyr?
Correct Answer: Option A — Groups the data frame by a specified column
Detailed Academic Explanation:
Groups the data frame by a specified column is the correct answer to “What does the group_by() function do in dplyr”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In dplyr, how do you select columns based on a partial name using the select() function?
Correct Answer: Option A — select(starts_with("partial_name"))
Detailed Academic Explanation:
select(starts_with("partial_name")) is the correct answer to “In dplyr, how do you select columns based on a partial name using the select() function”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What function is used to filter rows based on multiple conditions in dplyr?
Correct Answer: Option B — filter(multiple_conditions)
Detailed Academic Explanation:
filter(multiple_conditions) is the correct answer to “What function is used to filter rows based on multiple conditions in dplyr”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you perform an inner join between two data frames in dplyr using inner_join()?
Correct Answer: Option D — inner_join()
Detailed Academic Explanation:
inner_join() is the correct answer to “How do you perform an inner join between two data frames in dplyr using inner_join()”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In dplyr, how do you calculate the total count of observations in each group using summarize()?
Correct Answer: Option A — summarize(count = n())
Detailed Academic Explanation:
summarize(count = n()) is the correct answer to “In dplyr, how do you calculate the total count of observations in each group using summarize()”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the ungroup() function in dplyr?
Correct Answer: Option B — Removes the grouping of the data frame
Detailed Academic Explanation:
Removes the grouping of the data frame is the correct answer to “What is the purpose of the ungroup() function in dplyr”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you select distinct values from a column named category in dplyr using distinct()?
Correct Answer: Option D — distinct(category)
Detailed Academic Explanation:
distinct(category) is the correct answer to “How do you select distinct values from a column named category in dplyr using distinct()”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In dplyr, 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 dplyr, what does the slice() function do”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the rename_all() function do in dplyr?
Correct Answer: Option B — Renames all columns in a data frame
Detailed Academic Explanation:
Renames all columns in a data frame is the correct answer to “What does the rename_all() function do in dplyr”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you calculate the median of a numeric variable named price for each group in dplyr?
Correct Answer: Option A — summarize(median_price = median(price))
Detailed Academic Explanation:
summarize(median_price = median(price)) is the correct answer to “How do you calculate the median of a numeric variable named price for each group in dplyr”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In dplyr, how do you select columns that match a specific pattern using the select() function?
Correct Answer: Option B — choose_cols(matches("specific_pattern"))
Detailed Academic Explanation:
choose_cols(matches("specific_pattern")) is the correct answer to “In dplyr, how do you select columns that match a specific pattern using the select() function”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What function is used to remove missing values from a dplyr data frame?
Correct Answer: Option C — na_omit()
Detailed Academic Explanation:
na_omit() is the correct answer to “What function is used to remove missing values from a dplyr data frame”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In dplyr, how do you calculate the cumulative sum of a variable named sales within each group?
Correct Answer: Option D — mutate(cumsum = cumsum(sales))
Detailed Academic Explanation:
mutate(cumsum = cumsum(sales)) is the correct answer to “In dplyr, how do you calculate the cumulative sum of a variable named sales within each group”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How is the case_when() function used in dplyr?
Correct Answer: Option A — To create a switch case statement in a column
Detailed Academic Explanation:
To create a switch case statement in a column is the correct answer to “How is the case_when() function used in dplyr”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In dplyr, what does the slice_sample() function do?
Correct Answer: Option A — Samples random rows from a data frame
Detailed Academic Explanation:
Samples random rows from a data frame is the correct answer to “In dplyr, what does the slice_sample() function do”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In dplyr, what is the purpose of the distinct() function when used with multiple columns?
Correct Answer: Option A — Filters unique rows based on all specified columns
Detailed Academic Explanation:
Filters unique rows based on all specified columns is the correct answer to “In dplyr, what is the purpose of the distinct() function when used with multiple columns”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you create a new column total_price in dplyr that is the sum of two existing columns price1 and price2?
Correct Answer: Option D — mutate(total_price = price1 + price2)
Detailed Academic Explanation:
mutate(total_price = price1 + price2) is the correct answer to “How do you create a new column total_price in dplyr that is the sum of two existing columns price1 and price2”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the filter() function in dplyr?
Correct Answer: Option A — Removes rows based on specified conditions
Detailed Academic Explanation:
Removes rows based on specified conditions is the correct answer to “What is the purpose of the filter() function in dplyr”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you select columns from a dplyr data frame where the column names start with the letter 'a'?
Correct Answer: Option C — select(starts_with("a"))
Detailed Academic Explanation:
select(starts_with("a")) is the correct answer to “How do you select columns from a dplyr data frame where the column names start with the letter 'a'”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In dplyr, how do you calculate the sum and mean of a numeric variable named quantity for each group?
Correct Answer: Option A — summarize(total = sum(quantity), average = mean(quantity))
Detailed Academic Explanation:
summarize(total = sum(quantity), average = mean(quantity)) is the correct answer to “In dplyr, how do you calculate the sum and mean of a numeric variable named quantity for each group”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the role of the left_join() function in dplyr?
Correct Answer: Option A — Performs a left outer join between two data frames
Detailed Academic Explanation:
Performs a left outer join between two data frames is the correct answer to “What is the role of the left_join() function in dplyr”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In dplyr, how do you filter rows where a specific variable is within a range using filter()?
Correct Answer: Option B — filter(between(variable, lower_bound, upper_bound))
Detailed Academic Explanation:
filter(between(variable, lower_bound, upper_bound)) is the correct answer to “In dplyr, how do you filter rows where a specific variable is within a range using filter()”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you count the number of distinct values in a column named category in dplyr?
Correct Answer: Option D — n_distinct(category)
Detailed Academic Explanation:
n_distinct(category) is the correct answer to “How do you count the number of distinct values in a column named category in dplyr”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In dplyr, how do you filter rows based on multiple conditions using the AND logic?
Correct Answer: Option A — filter(condition1 & condition2)
Detailed Academic Explanation:
filter(condition1 & condition2) is the correct answer to “In dplyr, how do you filter rows based on multiple conditions using the AND logic”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the desc() function do in dplyr?
Correct Answer: Option A — Sorts a column in descending order
Detailed Academic Explanation:
Sorts a column in descending order is the correct answer to “What does the desc() function do in dplyr”. This question is standard in competitive examination syllabi for Data Manipulation With Dplyr.
💡Key Conceptual Anchor:Data Manipulation With Dplyr
✓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.