HW 2: Review on Vectors, Tibbles, and Pipes

Enter your name, answer the questions, then click Grade and Download PDF.

Short answers are auto-checked in a simple, forgiving way. Your instructor may review.

Multiple Choice (10)
1) Which of these do not create a vector in R?
2) Identify the function being used in the following code snippet:
c(6, 3, 2)
3) What is the result of the following code?
c(6, 3, 2) + c(3, 2, 1)
4) What does the following code return?
c("apple", "banana", "economics") %>% length()
5) Which of the following creates a vector with exactly five elements?
6) Which statement about sample() is true?
7) In a tibble, columns are best thought of as
8) Which rule must be satisfied when creating a tibble?
9) Suppose us_data is a tibble. What does the following code return?
us_data %>% names()
10) What does the pipe operator %>% do?
Short Answer (5)
SA1) What does the function c() do in R? Answer in one sentence.
SA2) What is the difference between a numeric vector and a character vector? Give a short example of each.
SA3) In a tibble, what is the difference between a variable and an observation?
SA4) Rewrite the following code using a pipe:
names(us_data)
SA5) Why is piping often preferred over nested function calls like g(f(x))? Answer briefly in plain language.

PDF note: This generates a PDF in your browser using jsPDF. If a school device blocks CDNs, you may need to download jsPDF and host it locally.