Q. How do you count the number of distinct values in a column named category in dplyr?

  • (A) count_distinct(category)
  • (B) distinct_count(category)
  • (C) calculate_distinct(category)
  • (D) n_distinct(category)
πŸ’¬ Discuss
βœ… Correct Answer: (D) n_distinct(category)

Q. In dplyr, how do you filter rows based on multiple conditions using the AND logic?

  • (A) filter(condition1 & condition2)
  • (B) filter_all_of(condition1, condition2)
  • (C) filter_condition(condition1 & condition2)
  • (D) filter(conditions = condition1, condition2)
πŸ’¬ Discuss
βœ… Correct Answer: (A) filter(condition1 & condition2)

Q. What does the desc() function do in dplyr?

  • (A) Sorts a column in descending order
  • (B) Describes the summary statistics of a column
  • (C) Discretizes a numeric column
  • (D) Disassembles a string column
πŸ’¬ Discuss
βœ… Correct Answer: (A) Sorts a column in descending order

Q. What is the purpose of the ungroup() function in dplyr?

  • (A) Retains the grouping of the data frame
  • (B) Removes the grouping of the data frame
  • (C) Unpacks nested data frames
  • (D) Reorders the rows based on a specific column
πŸ’¬ Discuss
βœ… Correct Answer: (B) Removes the grouping of the data frame

Q. How do you select distinct values from a column named category in dplyr using distinct()?

  • (A) distinct_values(category)
  • (B) select_distinct(category)
  • (C) unique(category)
  • (D) distinct(category)
πŸ’¬ Discuss
βœ… Correct Answer: (D) distinct(category)

Q. In dplyr, what does the slice() function do?

  • (A) Extracts specific rows from a data frame
  • (B) Selects specific columns from a data frame
  • (C) Slices a data frame into smaller data frames
  • (D) Sorts the data frame in ascending order
πŸ’¬ Discuss
βœ… Correct Answer: (A) Extracts specific rows from a data frame

Q. What does the rename_all() function do in dplyr?

  • (A) Renames all variables in a data frame
  • (B) Renames all columns in a data frame
  • (C) Renames all levels in a factor variable
  • (D) Renames all rows in a data frame
πŸ’¬ Discuss
βœ… Correct Answer: (B) Renames all columns in a data frame

Q. How do you calculate the median of a numeric variable named price for each group in dplyr?

  • (A) summarize(median_price = median(price))
  • (B) calculate_median(price)
  • (C) median_group(price)
  • (D) median(price)
πŸ’¬ Discuss
βœ… Correct Answer: (A) summarize(median_price = median(price))

Q. In dplyr, how do you select columns that match a specific pattern using the select() function?

  • (A) select(pattern = "specific_pattern")
  • (B) choose_cols(matches("specific_pattern"))
  • (C) select(columns = matches("specific_pattern"))
  • (D) pick_cols(pattern = "specific_pattern")
πŸ’¬ Discuss
βœ… Correct Answer: (B) choose_cols(matches("specific_pattern"))

Q. What function is used to remove missing values from a dplyr data frame?

  • (A) clean_na()
  • (B) remove_missing()
  • (C) na_omit()
  • (D) filter_na()
πŸ’¬ Discuss
βœ… Correct Answer: (C) na_omit()