Hi everyone ![]()
I’ve been working on some small sports analytics projects using the tidyverse, especially dplyr for wrangling and ggplot2 for visualization. For example, here’s a toy dataset where I look at player efficiency in basketball:
library(dplyr)
library(ggplot2)
set.seed(123)
players <- data.frame(
player = paste("Player", 1:10),
points = round(rnorm(10, mean = 15, sd = 5)),
assists = round(rnorm(10, mean = 5, sd = 2)),
rebounds = round(rnorm(10, mean = 7, sd = 3)),
minutes = round(runif(10, 20, 40))
)
players <- players %>%
mutate(points_per_min = points / minutes)
ggplot(players, aes(x = minutes, y = points_per_min, label = player)) +
geom_point(color = "blue", size = 3) +
geom_text(vjust = -0.8, size = 3) +
theme_minimal()
This kind of workflow works nicely for quick insights — but I’m curious: what other tidyverse functions/packages would you recommend for sports data analysis?
If anyone is interested in exploring further, I’ve also been writing about R and analytics here: rprogrammingbooks.com
Thanks in advance for your suggestions!