Git Product home page Git Product logo

rugger's Introduction

rugger

🇳🇿 🇮🇪 🏴󠁧󠁢󠁷󠁬󠁳󠁿 🏴󠁧󠁢󠁥󠁮󠁧󠁿 🇿🇦 🇦🇺 🏴󠁧󠁢󠁳󠁣󠁴󠁿 🇫🇯 [1]

rugger is a rrrrugby package 🏉. Get stats on teams, players, rankings and calculate changes in the rankings for a certain match.

Installation

You can install rugger with:

remotes::install_github("RobertMyles/rugger")

Usage

You can see the current world rankings with get_rankings():

library(rugger)
get_rankings()
#> # A tibble: 105 x 7
#>    team         team_abbr points  rank played previous_points previous_rank
#>    <chr>        <chr>      <dbl> <int>  <int>           <dbl>         <int>
#>  1 New Zealand  NZL         92.5     1    209            92.5             1
#>  2 Ireland      IRE         91.2     2    182            91.2             2
#>  3 Wales        WAL         87.2     3    196            86.7             3
#>  4 England      ENG         86.2     4    189            85.5             4
#>  5 South Africa RSA         84.6     5    200            85.1             5
#>  6 Australia    AUS         82.4     6    217            83.1             6
#>  7 Scotland     SCO         81.8     7    177            81.6             7
#>  8 Fiji         FJI         77.9     8    111            76.4            10
#>  9 France       FRA         77.3     9    187            78.9             8
#> 10 Argentina    ARG         77.0    10    182            77.3             9
#> # ... with 95 more rows

Hmmm, what would happen if New Zealand played Ireland tomorrow, and Ireland won by 5 points?

calculate_rank("New Zealand", "Ireland", score = c(15, 20))
#> # A tibble: 2 x 6
#>   team        points  rank points_exchanged new_points new_rank
#>   <chr>        <dbl> <int>            <dbl>      <dbl>    <int>
#> 1 Ireland       91.2     2             1.44       92.6        1
#> 2 New Zealand   92.5     1            -1.44       91.1        2

Yay, we’d jump into first place (sorry, biased!).

Let’s have a look at the history between England and Scotland, the first two teams to play the game:

get_team_records("England", "Scotland")
#> # A tibble: 1 x 15
#>   team  start_year end_year matches   won  lost  draw percent_won `for`
#>   <chr>      <dbl>    <dbl>   <int> <int> <int> <int>       <dbl> <int>
#> 1 Engl…       1871     2019     137    75    43    18        61.8  1636
#> # ... with 6 more variables: against <int>, difference <int>, tries <int>,
#> #   conversions <int>, penalties <int>, dropgoals <int>

England winning almost 62% of the matches there.

I wonder which player has scored most tries in rugby?

library(dplyr)

get_team_records(type = "player") %>% 
  arrange(desc(points))
#> # A tibble: 50 x 16
#>    player start_year end_year matches start   sub points tries conversions
#>    <chr>       <dbl>    <dbl>   <int> <int> <int>  <int> <int>       <int>
#>  1 DW Ca…       2003     2015     112   106     6   1598    29         293
#>  2 RJR O…       2000     2013     130    87    43   1083    16         176
#>  3 SM Jo…       1998     2011     110    91    19    970     7         160
#>  4 PC Mo…       1997     2008     102    90    12    893    25         153
#>  5 FA Vl…       2006     2018     113    89    24    888    11         159
#>  6 M Kvi…       2003     2018     115    94    21    840    17         148
#>  7 CD Pa…       1999     2011     109    96    13    809    22          90
#>  8 Y Kus…       2005     2018     101    89    12    733    10         136
#>  9 MJ Gi…       2002     2016     103    89    14    698    30         106
#> 10 BG Ha…       2004     2016     124   122     2    335    67           0
#> # ... with 40 more rows, and 7 more variables: penalties <int>,
#> #   dropgoals <int>, gfm <int>, won <int>, lost <int>, draw <int>,
#> #   percent_won <dbl>

The sublime Dan Carter!

Data etc.

All of the data acessed by this package is obviously for informational/educational use.

It belongs to World Rugby and ESPN. The algorithm that calculates the rankings also belongs to World Rugby, you can read about it here.

  1. Black flags?! They’re Github’s fault. The flags represent the rankings as of the tp 8 at the end of 2018 – New Zealand, Ireland, Wales, England, South Africa, Australia, Scotland and Fiji. You can see them in R with emo::ji("wales"), for example.

rugger's People

Contributors

thets avatar robertmyles avatar

Watchers

James Cloos avatar

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.