liveBook · Manning

Distinct value

As explained in Statistics Slam Dunk

The unique() function in R returns the distinct elements, rows, or combinations of values in an object.

The base R unique() function removes duplicate records, leaving one copy of each distinct row. This is useful when a vertical NBA game-data table repeats a game once for each official. section 9.3

Deduplicating NBA game records

After removing variables beginning with off, call NBAboxscores <- unique(NBAboxscores). Check the result with dim(NBAboxscores): the data falls from 44,284 rows to 14,758 rows while retaining 117 columns. section 9.3

NBAboxscores <- unique(NBAboxscores)
dim(NBAboxscores) 
## [1] 14758   117

Inspect the executable unique() call and its resulting row and column dimensions. section 9.3

How Statistics Slam Dunk covers it

How deep it goes
Explains why rows duplicate, applies unique(), and verifies dimensions, but does not detail the function’s internal algorithm.
Examples
Uses NBAboxscores records duplicated by officials and checks reduction from 44,284 rows to 14,758.
What it assumes
Assumes familiarity with an R data frame and teaches duplicate removal through a concrete NBA dataset.
What you can do after
Apply unique() to remove duplicate records and verify the cleaned data’s dimensions with dim().
How it connects
Connects distinct rows with select(), dim(), count(), filter(), and data wrangling.

Also explained in

Compare how 3 books explain distinct value →

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.