Represent the Data Before You Analyze It

A data frame is a rectangular table in which each row commonly represents one observational unit and each column represents one variable.


Its key advantage is that columns can have different types: a numeric measurement, a text label, a date, and a logical flag can coexist as long as every column has the same number of rows. A data frame is not just a matrix with headers.


An array generalizes indexed storage to multiple dimensions. A vector has one dimension, a matrix has two, and an array can have three or more.


Arrays are typically homogeneous: all elements share one atomic type. Dimensions give meaning to positions, such as subject by visit by measurement, and losing a dimension can silently change an operation's meaning.


Variable type is semantic as well as computational. Numeric values represent quantities for which arithmetic may make sense. Nominal categories such as region labels have no inherent order.


Ordered categories such as a response scale have rank but not necessarily equal spacing. Identifiers may be digits yet should not be averaged, and dates are temporal values rather than ordinary character labels.


Choose representation from the question. A numeric-looking code can be categorical, a yes/no value may be logical, and a category should not be converted to 1, 2, 3 merely to make a model accept it. Preserving types makes later summaries, joins, and modeling choices more auditable.

Which statement best describes a data frame used for a collection of observations?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A survey records a response as low, medium, or high. Which representation best preserves its meaning?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A researcher stores a homogeneous numeric array with dimensions [participants, visits, biomarkers]. What does the element at index [4,2,5] represent, assuming one-based indexing?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors