R at Bet Better
R for Betting-Market Data
Edward Glush. Bet Better Pty Ltd, 2026. First edition, 20 October 2026.
This is a short, free book about working with betting prices in R. It starts with one price and one sum, and ends with a live data feed. Along the way it shows how to turn odds into probabilities, how to remove the bookmaker's margin four different ways, how big that margin is across whole markets, whether the prices match what actually happens, and how prices move before a game starts. Every chapter uses base R or one small package, and every block of code was run against open data you can download yourself. The output under each block is the real output. The book is for analysts, students and anyone curious about how prices work. It is not betting advice.
Contents
- Prices and probabilities. Implied probability, overround, margin and fair odds in base R.
- Removing the margin: four methods. Proportional, additive, power and Shin margin removal in base R, checked against known results.
- The bookmaker margin index. Load the open daily margin index in R, summarise it by market type and plot it over time.
- Are the odds calibrated?. Reliability bands, binomial confidence intervals and the Brier score for vig-free betting odds, in base R.
- How prices move before kick-off. Opening vs closing bookmaker prices for 6,882 markets: measure the move by sport, price band and hours open in R.
- Using the free JSON feed from R. Read the free JSON feed of model win probabilities and fair odds with jsonlite, and handle empty and locked rows.
What you need
R 4.1 or later. Chapters 1 to 5 use base R only. Chapter 6 uses jsonlite (install.packages("jsonlite")). Chapters 3, 5 and 6 read files from the internet, so you need a connection.
The data
Licence
Text and code are licensed CC BY 4.0. You may copy, adapt and share them, including for teaching and commercial work, as long as you give credit with a link. The datasets carry their own CC BY 4.0 licences.
Cite this book
Glush, E. (2026). R for Betting-Market Data. Bet Better Pty Ltd. https://betbetter.world/rstats/book/
Corrections
Found a mistake, or code that no longer runs? Email edward@betbetter.world with the chapter and section number.
Data licensed CC BY 4.0, free to reuse with a credit. Model estimates, not advice. 18+. If gambling is causing you harm: gamblinghelponline.org.au.