getting-started.Rmd
This vignette provides an overview to get you started with using superNetballR
. As at 2018-04-08, this package contains the full 2017 season match statistics and player statistics.
Data are sourced from ‘https://mc.championdata.com/data/’ under certain match and round id’s. The 2017 home and away season is in the 10083 folder, whilst the finals are in the 10084 folder. The full (processed) data are supplied with this package.
To download statistics from a single match, you use the downloadMatch
function. As an example, the following code will download the match from round 5, game 3:
The downloaded object is a list, containing detailed statistics (including period-by-period statistics) for the match and players:
The full match data can be tidied into match and player statistics, grouped by period.
Tidying match statistics using the tidyMatch
function:
tidied_match <- tidyMatch(round5_game3)
tidied_match
#> # A tibble: 256 x 9
#> period squadId squadName squadNickname squadCode stat value round
#> <int> <int> <chr> <chr> <chr> <chr> <int> <int>
#> 1 1 8117 Sunshine Co… Lightning SCL reboun… 0 5
#> 2 2 8117 Sunshine Co… Lightning SCL reboun… 2 5
#> 3 3 8117 Sunshine Co… Lightning SCL reboun… 5 5
#> 4 4 8117 Sunshine Co… Lightning SCL reboun… 1 5
#> 5 1 8119 Magpies Net… Magpies MNC reboun… 2 5
#> 6 2 8119 Magpies Net… Magpies MNC reboun… 1 5
#> 7 3 8119 Magpies Net… Magpies MNC reboun… 1 5
#> 8 4 8119 Magpies Net… Magpies MNC reboun… 0 5
#> 9 1 8117 Sunshine Co… Lightning SCL goalsF… 9 5
#> 10 2 8117 Sunshine Co… Lightning SCL goalsF… 10 5
#> # ... with 246 more rows, and 1 more variable: game <int>
Tidying player statistics using the tidyPlayers
function:
tidied_players <- tidyPlayers(round5_game3)
tidied_players
#> # A tibble: 2,640 x 9
#> playerId period shortDisplayName firstname surname stat value round
#> <int> <int> <chr> <chr> <chr> <chr> <chr> <int>
#> 1 80010 1 Mentor, G Geva Mentor rebounds 0 5
#> 2 80010 2 Mentor, G Geva Mentor rebounds 1 5
#> 3 80010 3 Mentor, G Geva Mentor rebounds 3 5
#> 4 80010 4 Mentor, G Geva Mentor rebounds 1 5
#> 5 80105 1 Langman, L Laura Langman rebounds 0 5
#> 6 80105 2 Langman, L Laura Langman rebounds 0 5
#> 7 80105 3 Langman, L Laura Langman rebounds 0 5
#> 8 80105 4 Langman, L Laura Langman rebounds 0 5
#> 9 80113 1 Bassett, C Caitlin Bassett rebounds 0 5
#> 10 80113 2 Bassett, C Caitlin Bassett rebounds 1 5
#> # ... with 2,630 more rows, and 1 more variable: game <int>
Provided with the superNetballR
package is the full 2017 season match and player statistics in tidied format. These have been obtained using the previously described methods, tidied, and then combined by rows to produce a single data frame:
data(season_2017)
season_2017
#> # A tibble: 15,360 x 9
#> period squadId squadName squadNickname squadCode stat value round
#> <int> <int> <chr> <chr> <chr> <chr> <int> <int>
#> 1 1 806 NSW Swifts Swifts NSW rebounds 0 1
#> 2 2 806 NSW Swifts Swifts NSW rebounds 1 1
#> 3 3 806 NSW Swifts Swifts NSW rebounds 1 1
#> 4 4 806 NSW Swifts Swifts NSW rebounds 0 1
#> 5 1 8118 GIANTS Net… GIANTS GNB rebounds 1 1
#> 6 2 8118 GIANTS Net… GIANTS GNB rebounds 2 1
#> 7 3 8118 GIANTS Net… GIANTS GNB rebounds 2 1
#> 8 4 8118 GIANTS Net… GIANTS GNB rebounds 1 1
#> 9 1 806 NSW Swifts Swifts NSW goalsFr… 6 1
#> 10 2 806 NSW Swifts Swifts NSW goalsFr… 13 1
#> # ... with 15,350 more rows, and 1 more variable: game <int>
Using a dataset that contains all matches up to a given round in a season means it is easy to reproduce ladder positions. A ladders
function is provided that can be used on full season data. For example, here is the ladder as it stood at the end of the 2017 home and away season:
ladder <- ladders(season_2017, round_num = 14)
ladder
#> # A tibble: 8 x 7
#> squadName games goals_for goals_against percentage points points_new
#> <chr> <int> <int> <dbl> <dbl> <int> <int>
#> 1 Melbourne Vi… 14 874 744 1.17 23 85
#> 2 Sunshine Coa… 14 808 726 1.11 23 79
#> 3 GIANTS Netba… 14 773 728 1.06 20 68
#> 4 Magpies Netb… 14 770 730 1.05 18 63
#> 5 Queensland F… 14 778 756 1.03 15 58
#> 6 NSW Swifts 14 726 792 0.917 7 32
#> 7 West Coast F… 14 670 779 0.860 4 25
#> 8 Adelaide Thu… 14 648 792 0.818 2 16
The round number is provided above, as the home and away season contained 14 rounds.