Knowledge Quiz: Factors

Note
  • Click the check-mark button to check your answer.
  • Click the question-mark button to see an explanation of the solution.

Consider the factor f1 generated by the following code.

v1 <- sample(1:3, 10, TRUE)
f1 <- factor(v1, levels = 1:3, labels = 3:1)

What will the expression levels(f1) return?

  • Correct
  • Wrong: This vector is ordered incorrectly.
  • Wrong: Factor level names are always character values.
  • Wrong: Factor level names are always character values (these numbers are also ordered incorrectly).
  • Wrong: This is the number of levels, nlevels(f1).
  • Wrong: f1 has ten elements, but it has only three levels.
  • Wrong: f1 has ten elements, but it has only three levels.
  • Wrong: f1 has ten elements, but it has only three levels.
Back to top