liveBook · Manning

Long data

As explained in Statistics Slam Dunk

Long format is a tabular arrangement in which repeated measurements are represented as separate rows with variable-identifying columns.

Long data stores repeated measurements in separate rows, with columns identifying the measured variable and its context. Compared with wide data, this arrangement often fits analysis and visualization workflows more naturally. section 2.7 section 2.1

A wide NBA table can become long data by:

  • Selecting the identifier column, such as Team, and the repeated year or season columns. section 14.2.1
  • Using tidyr::pivot_longer() to move former column names into an identifier column and former cell values into a measurement column. section 14.2.1
  • Checking dimensions and sample rows to confirm that each record represents one team-and-season combination. section 14.2.1
first_salaries %>%
 pivot_longer(col = c(w2017:w2008),
              names_to = "year",
              values_to = "wins") -> first_stats

second_salaries %>%
 pivot_longer(col = c(pc2017:pc2008),
              names_to = "season",
              values_to = "playoffs") -> second_stats

Reshape regular-season wins and postseason results into long tibbles with meaningful identifier and value columns. section 14.2.1

How Statistics Slam Dunk covers it

How deep it goes
Explains reshaping through column selection, pivot_longer(), dimensions, and sample rows, without developing internals.
Examples
Uses NBA team win totals and postseason results across the 2008–2017 seasons.
What it assumes
Assumes basic tabular data and R familiarity while demonstrating the reshaping operation step by step.
What you can do after
Apply it via tidyr::pivot_longer() to produce analysis-ready team-and-season records.
How it connects
Connects wide format, data wrangling, data visualization, tidyverse, and tidyr.

Also explained in

Compare how 2 books explain long data →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Slam Dunk. The section links point to the parts of the book it draws on.