runner is an R package for scoping and sizing streaks. Its streak_run() function computes running sequences of consecutive values, making it useful for questions such as whether free-throw success follows a hot hand. section 16.1 section 16.4.1
library(tidyverse) library(runner)
Load runner alongside tidyverse before preparing and analyzing sequential data. section 16.1
Measure free-throw streaks
Filter Giannis Antetokounmpo’s 707 free-throw records, then group by game date and create streak = streak_run(lag(points)). Grouping by date prevents a streak from carrying into another game. The resulting table counts makes and misses by streak length, calculates percentages, and supports a line chart of shooting percentage after consecutive makes. section 16.4.1
Compare with random sequences
Generate 700 fair coin flips with sample(), calculate streak_run(heads_tails), retain heads, and find the maximum streak. The simulated sequence reaches a run of 11 heads.
