liveBook · Manning

Rbind() function

As explained in Statistics Slam Dunk

The base R rbind() function combines vectors, matrices, or data frames by rows into a single object.

rbind() is base R’s row-binding function: it joins two or more vectors, matrices, or data sets by rows into one object. Use it when observations belong underneath one another, rather than when variables need to be matched side by side. section 4.7 section 14.7

For data sets, compatible structure matters. Two data sets can be stacked when they have the same width and variable names; differing structures produce an error. Column order does not have to match. After binding, check dim() to confirm that row counts were added while the column count stayed unchanged. section 6.3.2 section 14.2.4

Combine NBA seasons into one analysis table

Each season contributes 30 team records with 27 variables. Row-binding 10 season-level data sets produces 300 records while retaining 27 columns. A season variable can then identify where each block of rows came from. section 14.2.4

nbadf1 <- rbind(nba1819, nba1920)
dim(nbadf1)
## [1] 4146   57

This compact call stacks two season-level game data sets, then uses dim() to verify the combined 4,146-row, 57-variable result. section 6.3.2

Row-binding also supports analysis preparation beyond season files. It can consolidate separately prepared team records before computing z-scores or K-means inputs, combine regular-season and playoff measurements before a paired plot, or assemble binary position vectors into a constraint matrix. section 4.7 section 11.4.1 section 11.5.1 section 14.7

How Statistics Slam Dunk covers it

How deep it goes
Defines row-binding, states data-frame compatibility requirements, and demonstrates dimension checks and several analysis-ready outputs.
Examples
Demonstrates stacked NBA seasons, team salary-and-win summaries, regular-season versus playoff records, and binary position constraints.
What you can do after
Apply it via base R to stack compatible vectors, matrices, or data sets and verify the resulting dimensions.
How it connects
Connects row-binding with matrices, dim(), dplyr select(), mutate(), K-means clustering, z-scores, and paired plots.

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.