Knowledge Quiz: Data Frames

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

Consider the following data frame, df.

   name age height  eyes
1   bob  25    180 green
2  mike  23    178 green
3  mark  24    169  blue
4 steve  26    183 brown

How can we extract the name column and return the selection as a character vector?

  • Wrong: This command will return the name and age columns as a \(4 \times 2\) data frame.
  • Correct
  • Correct
  • Wrong: This command will return the name column as a one-column data frame.
  • Wrong: This command will return the first row of df as a \(1 \times 4\) data frame.

Consider the following data frame, df.

   name age height  eyes
1   bob  25    180 green
2  mike  23    178 green
3  mark  24    169  blue
4 steve  26    183 brown

How can we extract the height column and return the selection as a data frame?

  • Wrong: This command will return the height column as a numeric vector.
  • Wrong: This command will return the height column as a numeric vector.
  • Correct
  • Wrong: This command will return the age column as a numeric vector.
  • Wrong: This command will return the height column as a numeric vector.
Back to top