Sports Analytics in Practice with R
eBook - ePub

Sports Analytics in Practice with R

  1. English
  2. ePUB (mobile friendly)
  3. Available on iOS & Android
eBook - ePub

Sports Analytics in Practice with R

About this book

Sports Analytics in Practice with R

A practical guide for those looking to employ the latest and leading analytical software in sport

In the last twenty years, sports organizations have become a data-driven business. Before this, most decisions in sports were qualitatively driven by subject-matter experts. In the years since numerous teams found success with "Money Ball" analytical perspectives, the industry has sought to advance its analytical acumen to improve on- and off-field outcomes. The increasing demand for data to inform decisions for coaches, scouts, and players before and during sporting events has led to intriguing efforts to build upon this quantitative approach.

As this methodology for assessing performance has matured and grown in importance, so too has the open-source R software emerged as one of the leading analytical software packages. In fact, R is a top 10 programming language that is useful in academia and industry for statistics, machine learning, and rapid prototyping. Sports Analytics in Practice with R neatly marries these two advances to teach basic analytics for sports-related use—from cricket to baseball, from basketball to tennis, from soccer to sports gambling, and more.

Sports Analytics in Practice with R readers will also find:

  • A broad perspective of sports, focusing on a wide range of sports rather than just one
  • The first book of its kind that features coding examples
  • Case study approach throughout the book
  • Companion website including data sets to work through alongside the explanations

Sports Analytics in Practice with R is a helpful tool for students and professionals in the sports management field, but also for sports enthusiasts who have a coding background.

Trusted by 375,005 students

Access to over 1.5 million titles for a fair monthly price.

Study more efficiently using our study tools.

Information

Publisher
Wiley
Year
2022
Print ISBN
9781119598077
eBook ISBN
9781119598091

1
Introduction to R

Objectives

  • Learn about R as a programming language
  • Define Integrated Development Environment
  • Define objects
  • Learn the assignment operator
  • Define functions
  • Executing a loop
  • Learn logical operators
  • Learn about R data types
  • Learn about object classes
  • Indexing data objects
  • Extending R functionality with packages
  • Writing a custom function
  • Create a scatter plot with sports data
  • Create a heatmap with sports data

R Libraries

 ggplot2 ggthemes RCurl tidyr 

R Functions

 + plot <- round class as.factor as.character c cbind rbind data.frame as.matrix as.data.frame install.packages library getURL read.csv dim names head tail summary table qplot pivot_longer geom_tile scale_fill_gradient xlab ggtitle theme theme_hc 

The R Programming Language

R is an open-source, freely available programming language used throughout this book. R is a powerful and longstanding programming language developed more than 20 years ago. It is a derivative of the “S” programming language for statistics originating in the mid-1990s developed by AT&T and Lucent Technologies. Unlike other programming languages, R is optimized specifically for statistics including but not limited to simulation, machine learning, visualizations, and traditional statistical modeling (linear regression) as well as tests. Due to the open-source nature of R, many developers, academics, and enthusiasts have contributed to its development for their specific needs. As a result, the language is extensible meaning it can be easily used for various purposes. For example, through R markdown, simple websites and presentations can be created. In another use case, R can be used for traditional linear modeling or machine learning and can draw upon various data types for analysis including audio files, digital images, text, numeric, and various other data files and types. Thus, it is widely used and nonspecialized other than to say R is an analysis language. This differs from other languages which specialize in web development like Ruby or python which has extended its functionality to building applications not just analysis.
In this textbook, the R language is applied specifically to sports contexts. Of course, the code in this book can be used to extend your understanding of sports analytics. It may give you insights to a particular sport or analytical aspect within the sport itself such as what statistics should be focused on to win a basketball game. However, learning the code in this book can also help open up a world of analytical capabilities beyond sports. One of the benefits of learning statistics, programming, and various analysis methods with sports data is that the data is widely available and outcomes are known. This means that your analysis, models, and visualizations can be applied, and you can review the outcomes as you expand upon what is covered in this book. This differs from other programming and statistical examples which may resort to boring, synthetic data to illustrate an analytical result. Using sports data is realistic and can be future oriented, making the learning more challenging yet engaging. Modeling the survivors of the Titanic pales in comparison since you cannot change the historical outcome or save future cruise ship mates. Thus, modeling which team will win a match or which player is a good draft pick is a superior learning experience.
If you are new to programming don’t be intimidated. R is a forgiving language in that things like spacing an indentation are ignored. Further, the R community is well supported and a simple online search of any error message usually finds an answer quickly on any number of sites.
To begin your R and sports analytics journey, please download the “base-R” distribution for your operating system. The “Comprehensive R Archive Network,” CRAN, is the home of the official R distribution as well as officially supported packages (more on that in a bit). The site to download base-R is https://cran.r-project.org.
Unfortunately, base-R, having started in the nineties, looks abysmal and lacks some modern day functionality. Thus, you will need to next download the R-Studio Integrated Development Environment, or IDE. An IDE is software that consolidates many of the aspects needed to code into one place. For example, you will need to write code which could be done in a simple notepad like program, a place to execute the code written, a place to visualize plots that were output from the code, and so on. These individual components are assembled into the IDE for ease of use and fast development. R and many other languages have IDEs. In fact, R has multiple IDE optimized for the type of analysis you are performing such as biostatistics or working with another language like Java. The most popular and easily supported IDE for base-R is the R-Studio software. There are server and desktop versions available. The code executed in this book should work for either cloud or local but installation of base-R and R-Studio on a server is not covered. Therefore, please download the R-Studio desktop IDE by navigating to https://www.rstudio.com/products/rstudio.
The R-Studio IDE, or Integrated Development Environment, adds functionality and modern user interface to base-R. The IDE aggregates common functionality used for software development and statistical analysis.
Essentially R-Studio sits on top of base-R. The IDE provides a modern GUI expected of today’s computer users while also adding functionality including the use of version control, terminal access and perhaps most importantly an easy way to create and view visualizations for easy export and saving to disk. Figure 1.1 illustrates the basic relationship for base-R and R-Studio. As you can see with...

Table of contents

  1. Cover
  2. Title page
  3. Copyright
  4. Table of Contents
  5. Preface
  6. Author Biography
  7. Foreword
  8. 1 Introduction to R
  9. 2 Data Visualization: Best Practices
  10. 3 Geospatial Data: Understanding Changing Baseball Player Behavior
  11. 4 Evaluating Players for the Football Draft
  12. 5 Logistic Regression: Explaining Basketball Wins and Losses with Coefficients
  13. 6 Gauging Fan Sentiment in Cricket
  14. 7 Gambling Optimization
  15. 8 Exploratory Data Analysis: Searching Data for Opponent Insights
  16. Index
  17. End User License Agreement

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.5M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1.5 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access Sports Analytics in Practice with R by Ted Kwartler in PDF and/or ePUB format, as well as other popular books in Medicine & Probability & Statistics. We have over 1.5 million books available in our catalogue for you to explore.