convert_results returns a dataframe containing the results in long format.

convert_results(results)

Arguments

results

A dataframe that has been returned from get_match_results

Value

A data frame with match results where each row is a team-match combination

Details

The standard results returned by afltables.com will be in wide format. This is useful for game based analysis but less so for team based ones. This function converts the data into long format for easier analysis.

Examples

results <- get_match_results() convert_results(results)
#> # A tibble: 30,814 x 13 #> Game Date Round Venue Margin Season Round.Type Round.Number Status #> <dbl> <date> <chr> <chr> <dbl> <dbl> <chr> <int> <chr> #> 1 1 1897-05-08 R1 Brun… 33 1897 Regular 1 Home #> 2 1 1897-05-08 R1 Brun… -33 1897 Regular 1 Away #> 3 2 1897-05-08 R1 Vict… 25 1897 Regular 1 Home #> 4 2 1897-05-08 R1 Vict… -25 1897 Regular 1 Away #> 5 3 1897-05-08 R1 Cori… -23 1897 Regular 1 Home #> 6 3 1897-05-08 R1 Cori… 23 1897 Regular 1 Away #> 7 4 1897-05-08 R1 Lake… -17 1897 Regular 1 Home #> 8 4 1897-05-08 R1 Lake… 17 1897 Regular 1 Away #> 9 5 1897-05-15 R2 Lake… 4 1897 Regular 2 Home #> 10 5 1897-05-15 R2 Lake… -4 1897 Regular 2 Away #> # ... with 30,804 more rows, and 4 more variables: Behinds <chr>, Goals <chr>, #> # Points <chr>, Team <chr>