Multiple Choices: Vectors

Questions

  1. What function is commonly used to create a sequence of numbers in a vector? ::: {.cell}
  1. Which function combines multiple values into a single vector in R?
  1. What will be the output of the following code: c(1, 2, 3) + c(4, 5, 6)?
  1. Which function is used to determine the type of elements in a vector?
  1. What will be the output of length(c(10, 20, 30, 40))?
  1. If x <- c(5, 10, 15, 20, 25), what is the output of x[2]?
  1. What is the result of sum(c(2, 4, 6, 8, 10))?
  1. Which of the following functions will check if an object is a vector?
  1. What will be the result of c(1, 2, 3) * 2?
  1. If y <- c("apple", "banana", "cherry"), what is the result of y[2:3]?
  1. What is the output of the following code: rep(1, times = 5)?
  1. What does the function mean() do when applied to a numeric vector?
  1. What will be the output of c(1, 2, 3) > 2?
  1. Which function would you use to remove duplicate elements from a vector in R?
  1. If z <- c(1, 2, NA, 4), what will be the result of mean(z, na.rm = TRUE)?
  1. Which operator will concatenate two vectors in R?
  1. What will be the output of c(TRUE, FALSE, TRUE) & c(TRUE, TRUE, FALSE)?
  1. What does sum(c(TRUE, FALSE, TRUE, FALSE, TRUE)) return?
  1. Which function would you use to reverse the order of elements in a vector?
  1. If x <- c(3, 6, 9, 12, 15), what does x[x > 9] return?
  1. What is the result of c(1, "2", 3) in R?
  1. Which function would you use to repeat each element of a vector a specified number of times?
  1. What will x[1:3] <- c(10, 20, 30) do to x <- c(1, 2, 3, 4, 5)?
  1. What will the expression 1:5 * 2 return?
  1. What is the output of which(c(FALSE, TRUE, FALSE, TRUE))?
  1. What will be the output of any(c(FALSE, FALSE, TRUE))?
  1. What will x <- c(5, 10, 15); y <- x * x > 25 set y to?
  1. What is the result of c(1, 2, NA, 4) == NA in R?
  1. Which function would you use to sort a vector in ascending order?
  1. If z <- c("a", "b", "c", "d"), what does z[c(FALSE, TRUE, TRUE, FALSE)] return?

:::