Q. How do you remove a column named Income from a data frame named my_data in R?

  • (A) my_data <- my_data[, -which(names(my_data) == "Income")]
  • (B) my_data$Income <- NULL
  • (C) drop_column(my_data, "Income")
  • (D) remove_col(my_data, "Income")
πŸ’¬ Discuss
βœ… Correct Answer: (B) my_data$Income <- NULL

Q. In R, what does the unlist() function do?

  • (A) Converts a list to a vector
  • (B) Reverses the order of elements
  • (C) Creates an unsorted list
  • (D) Extracts unique elements from a vector
πŸ’¬ Discuss
βœ… Correct Answer: (A) Converts a list to a vector

Q. How is a character string converted to a numeric vector in R using the as.numeric() function?

  • (A) as.numeric("123")
  • (B) numeric("123")
  • (C) convert_numeric("123")
  • (D) to_numeric("123")
πŸ’¬ Discuss
βœ… Correct Answer: (A) as.numeric("123")

Q. In R, what is the purpose of the subset() function?

  • (A) Create a subset of a data frame based on conditions
  • (B) Generate a summary of a data frame
  • (C) Filter data based on row and column indices
  • (D) Extract unique values from a vector using subsetting
πŸ’¬ Discuss
βœ… Correct Answer: (A) Create a subset of a data frame based on conditions

Q. How do you add a new row to a data frame named my_data with values "Alice" and 28 for columns Name and Age?

  • (A) my_data <- rbind(my_data, c("Alice", 28))
  • (B) my_data <- add_row(my_data, Name = "Alice", Age = 28)
  • (C) my_data$Name <- "Alice"; my_data$Age <- 28
  • (D) append_row(my_data, c("Alice", 28))
πŸ’¬ Discuss
βœ… Correct Answer: (B) my_data <- add_row(my_data, Name = "Alice", Age = 28)

Q. What function is used to concatenate two vectors in R?

  • (A) concat()
  • (B) paste()
  • (C) c()
  • (D) combine()
πŸ’¬ Discuss
βœ… Correct Answer: (C) c()

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

  • (A) Extracts specific rows from a data frame
  • (B) Dices a vector into smaller slices
  • (C) Counts the number of slices in a vector
  • (D) Slices a data frame into smaller data frames
πŸ’¬ Discuss
βœ… Correct Answer: (A) Extracts specific rows from a data frame

Q. How do you create a named numeric vector with values 1, 2, and 3 named "one", "two", and "three" in R?

  • (A) named_vector <- c(one = 1, two = 2, three = 3)
  • (B) create_named_vec(1, 2, 3, names = c("one", "two", "three"))
  • (C) numeric_vector(c(1, 2, 3), names = c("one", "two", "three"))
  • (D) vec_named(c(1, 2, 3), c("one", "two", "three"))
πŸ’¬ Discuss
βœ… Correct Answer: (D) vec_named(c(1, 2, 3), c("one", "two", "three"))

Q. How do you check the structure of a data frame named my_data in R?

  • (A) struct(my_data)
  • (B) str(my_data)
  • (C) structure(my_data)
  • (D) check_structure(my_data)
πŸ’¬ Discuss
βœ… Correct Answer: (B) str(my_data)

Q. In R, what is the purpose of the names() function?

  • (A) Retrieve the number of elements in an object
  • (B) Set or retrieve names of an object
  • (C) Assign names to the elements
  • (D) Remove names from an object
πŸ’¬ Discuss
βœ… Correct Answer: (C) Assign names to the elements