Giter Club home page Giter Club logo

eurolig's Introduction

eurolig

lifecycle

The eurolig package provides a set of tools to obtain and analyze basketball generated data from the Euroleague.

Overview

  • API wrapper around the official website of the Euroleague.

  • Functions to obtain stats, play-by-play data and shot location data in a tidy format within R.

  • Tools to analyze and visualize the data.

Installation

# install.packages("devtools")
devtools::install_github("solmos/eurolig")

Example

Let’s say we want to analyze play-by-play data from the Championship game of the 2017-2018 season between Real Madrid and Fenerbache Dogus Istanbul. We can obtain the data by entering the game code and the season to the function extractPbp(). The game code for the game can be found in the game’s URL.

library(eurolig)
pbp <- extractPbp(game_code = 260, season = 2017)
pbp
#> # A tibble: 583 x 29
#>    season game_code play_number team_code player_name play_type
#>     <int>     <dbl>       <int> <chr>     <chr>       <chr>    
#>  1   2017       260           2 <NA>      <NA>        BP       
#>  2   2017       260           3 MAD       AYON, GUST… TPOFF    
#>  3   2017       260           4 ULK       GUDURIC, M… TPOFF    
#>  4   2017       260           5 ULK       DUVERIOGLU… 2FGM     
#>  5   2017       260           6 ULK       GUDURIC, M… AST      
#>  6   2017       260           7 ULK       VESELY, JAN CPF      
#>  7   2017       260           8 MAD       REYES, FEL… RPF      
#>  8   2017       260           9 MAD       AYON, GUST… 2FGA     
#>  9   2017       260          10 MAD       AYON, GUST… ORB      
#> 10   2017       260          11 ULK       GUDURIC, M… CPF      
#> # … with 573 more rows, and 23 more variables: time_remaining <chr>,
#> #   quarter <dbl>, points_home <dbl>, points_away <dbl>, play_info <chr>,
#> #   seconds <dbl>, home_team <chr>, away_team <chr>, home <lgl>,
#> #   team_name <chr>, last_ft <lgl>, and1 <lgl>, home_player1 <chr>,
#> #   home_player2 <chr>, home_player3 <chr>, home_player4 <chr>,
#> #   home_player5 <chr>, away_player1 <chr>, away_player2 <chr>,
#> #   away_player3 <chr>, away_player4 <chr>, away_player5 <chr>,
#> #   lineups <chr>

From these data we can extract information about the assists in that game from, say, Real Madrid (MAD):

assists <- getAssists(pbp, team = "MAD")
assists
#> # A tibble: 16 x 13
#>    season game_code team_code passer shooter shot_type points
#>     <int>     <dbl> <chr>     <chr>  <chr>   <chr>      <dbl>
#>  1   2017       260 MAD       FERNA… LLULL,… 3FG            3
#>  2   2017       260 MAD       LLULL… RANDOL… 3FG            3
#>  3   2017       260 MAD       FERNA… TAYLOR… 2FG            2
#>  4   2017       260 MAD       LLULL… TAVARE… 2FG            2
#>  5   2017       260 MAD       DONCI… CARROL… 2FG            2
#>  6   2017       260 MAD       TAYLO… THOMPK… 2FG            2
#>  7   2017       260 MAD       DONCI… TAVARE… 2FG            2
#>  8   2017       260 MAD       DONCI… CARROL… 3FG            3
#>  9   2017       260 MAD       AYON,… CAUSEU… 3FG            3
#> 10   2017       260 MAD       CAUSE… REYES,… 2FG            2
#> 11   2017       260 MAD       DONCI… CAUSEU… 3FG            3
#> 12   2017       260 MAD       CAUSE… REYES,… 2FG            2
#> 13   2017       260 MAD       FERNA… DONCIC… 3FG            3
#> 14   2017       260 MAD       TAVAR… LLULL,… <NA>           0
#> 15   2017       260 MAD       TAVAR… CARROL… 3FG            3
#> 16   2017       260 MAD       THOMP… TAVARE… 2FG            2
#> # … with 6 more variables: time_remaining <chr>, quarter <dbl>,
#> #   seconds <int>, foul <lgl>, and1 <lgl>, ftm <dbl>

Shot location data can also be retrieved and visualized:

shots <- extractShots(260, 2017)
plotShotchart(shots)

eurolig's People

Contributors

solmos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

eurolig's Issues

getAssists not working when no free throw assists

I get this message:

Error in UseMethod("group_by_") :
no applicable method for 'group_by_' applied to an object of class "NULL"

I got all the function to see what was going on and realized there were no free throws assisted for one team, which makes "ft_list" being empty and "ft_df" failing.

extractStarters not working

The Eurolig website has changed where and how it displays boxscores so extractStarters() returns an empty vector since it cannot find starters in the boxscore.

This means attachLineups() will not work either.

Should use lineups = FALSE in extractPbp() until this is fixed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.