A Sports Statistics Problem Solved in 30 Lines of Tidyverse Code
A Sports Statistics Problem Solved in 30 Lines of Tidyverse Code
When Scott Nestler announced via slack channel that he'd released a new edition of his sports statistics book, I was curious whether it would make a great gift for my dad, who loves horse racing. After some online searches didn't tell me how much of the book concerned horse racing, I started typing a message to Scott to ask. Mid-message, I realised I could probably answer it myself. A quick search for the book's title with search operator filetype:pdf located a copy. It's 377 pages. I could control + f for horse racing, but my dad likes other sports too, so I figured I'd come this far, let's take a second and do this properly. Wikipedia had a lit of all sports but it's a tad too comprehensive for what I needed, so I grabbed a list of sports off another site that came up when I searched for a list of sports. I wrote 30 lines of tidyverse code [1] that downloads the 377 page pdf, parses every word in it, filters on the list of sports, groups by word, and provides the number of occurrences of each sport in descending order: providing a rough indicator of how much of the book is dedicated to each sport, all in a few minutes of coding. As someone who codes a lot in ruby, I have a high bar for 'developer happiness', but say without hesitation that R and its tidyverse are joy: expressive (almost always read left to right, top to bottom - just like the prose of a book), fast, reliable, succinct, and productive. For anyone put off by R's indexing starting at 1 rather than 0, or by use of <- instead of = for assignment, I encourage you to suspend your hesitation for a short while to discover the tidyverse: you may well discover it to be a pure joy. [1] https://i.imgur.com/E64yF4Y.png [2] https://pastebin.com/Danc9KNr
Share cardActual performance
Launch Intel predictions
Analyze your own launch →Incorrect prediction on native model
Similar products
Monty Hall problem, with 30 doors
Spinlock in 30 Lines of C
Own MobX in 65 lines of code
Implement MFA in two lines of code
30 vs. 3000 lines of code for very simple MEAN app
Build a Video RAG under 30 lines of code
Go-dutchflag – An implementation of the Dutch flag problem in Golang
The AZ Problem
Someone Else's Problem
The problem with the epsilon greedy method