6 More wrangling and visualizing data

 

This chapter covers

  • Subsetting data sets
  • Separating and joining data sets
  • Renaming and converting variables
  • Sorting data and returning cumulative sums
  • Transforming data sets
  • Indexing records
  • Converting sqldf code to dplyr
  • Creating and customizing bar charts

According to conventional wisdom, no doubt influenced by late-game bias where the final plays in a close game create the most indelible memories, NBA games are won in the fourth quarter. In other words, teams that win the fourth quarter and play best down the stretch, regardless of what might have happened over the first three quarters, will usually be victorious. This suggests that the last 12 minutes of an NBA game are more significant than the first 36 minutes (NBA games are 48 minutes in duration divided into four 12-minute quarters).

6.1 Loading packages

6.2 Importing data

6.3 Wrangling data

6.3.1 Subsetting data sets

6.3.2 Joining data sets

6.4 Analysis

6.4.1 First quarter

6.4.2 Second quarter

6.4.3 Third quarter

6.4.4 Fourth quarter

6.4.5 Comparing best and worst teams

6.4.6 Second-half results