-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
146 lines (101 loc) · 5.96 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
---
output:
github_document:
html_preview: false
---
```{r setup, include=FALSE}
library(knitr)
knitr::opts_chunk$set(
warning = FALSE,
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/",
out.width = "100%"
)
```
# squashinformr <img src="man/figures/logo.png" align="right" />
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![CRAN status](https://www.r-pkg.org/badges/version/squashinformr)](https://CRAN.R-project.org/package=squashinformr)
[![CRAN Downloads](https://cranlogs.r-pkg.org/badges/squashinformr)](https://cranlogs.r-pkg.org/badges/squashinformr)
[![CRAN total](https://cranlogs.r-pkg.org/badges/grand-total/squashinformr)](https://cranlogs.r-pkg.org/badges/grand-total/squashinformr)
[![R build status](https://github.com/HaydenMacDonald/squashinformr/workflows/R-CMD-check/badge.svg)](https://github.com/HaydenMacDonald/squashinformr/actions)
[![Codecov test coverage](https://codecov.io/gh/HaydenMacDonald/squashinformr/branch/main/graph/badge.svg)](https://app.codecov.io/gh/HaydenMacDonald/squashinformr)
[![CodeFactor](https://www.codefactor.io/repository/github/haydenmacdonald/squashinformr/badge)](https://www.codefactor.io/repository/github/haydenmacdonald/squashinformr)
[![Tutorial](https://img.shields.io/badge/-Tutorial%20Blog%20Post-blue?style=flat&logo=RSS&logoColor=white)](https://needleinthehay.ca/post/introducing-squashinformr/)
<!-- badges: end -->
## Overview
**squashinformr** allows users to easily scrape <a href="http://www.squashinfo.com/" target="_blank">SquashInfo</a> for data on the Professional Squash Association World Tour and other squash tournaments. The functions within this package scrape, parse, and clean data associated with players, tournaments, and rankings.
## Installation
Install `squashinformr` via CRAN:
```{r, eval=FALSE, message=FALSE, warning=FALSE}
install.packages("squashinformr")
```
Install the development version of `squashinformr` from this GitHub repository via:
```{r, eval=FALSE, message=FALSE, warning=FALSE}
if (!require("remotes")) install.packages("remotes")
remotes::install_github("HaydenMacDonald/squashinformr")
```
## Usage
There are three major families of scraping functions in `squashinformr`:
- Player functions for scraping player profile data
- `get_players()`
- `get_player_recent_results()`
- `get_player_recent_matches()`
- `get_player_recent_games()`
- `get_matchup()`
- Tournament functions for scraping tournament results data
- `get_tournaments()`
- `get_tournament_players()`
- `get_tournament_matches()`
- `get_tournament_games()`
- Ranking function for scraping current and historical rankings tables
- `get_rankings()`
## Examples
### `get_player_recent_matches()`
This function returns a player's recent matches.
```{r}
library(squashinformr)
## Get Mohamed Elshorbagy's most recent match data
get_player_recent_matches(player = "Mohamed Elshorbagy", category = "mens")
```
### `get_tournament_games()`
This function returns a tournament's game results data.
```{r}
## Return game data for 2020's Black Ball Open.
get_tournament_games("Black Ball Open", year = 2020, world_tour = TRUE)
```
### `get_rankings()`
This function returns data from the most recent PSA rankings tables.
```{r, message=FALSE, warning=FALSE}
library(dplyr)
## Get the top 5 players in both men's and women's singles competitions
get_rankings(top = 5, category = "both") %>%
arrange(category, rank)
```
### `get_matchup()`
This function returns recent head-to-head matchup stats between two players. Stats returned include:
- each player's rank and name
- total matches played
- the number of matches won
- the match results spread (relative to player 1)
- the average match time
- the number of games played
- the number of games won
- average point advantage in a won game
- the average point difference in final scores
- the number of tie-break wins
- and the percentage of games that go to a tie-breaker.
```{r, message=FALSE, warning=FALSE}
## Get tidy matchup stats for Paul Coll vs Fares Dessouky
get_matchup("Paul Coll", "Fares Dessouky", category = "mens", tidy = FALSE)
```
## Help
Submit issues here on GitHub.
If you are interested in extending the functionality of this package, fork this repository, make your changes and submit them as a pull request. The `squashinformr` project is released with a <a href="https://github.com/HaydenMacDonald/squashinformr/blob/main/.github/CODE_OF_CONDUCT.md" target="_blank">Contributor Code of Conduct</a>. By contributing to this project, you agree to its terms.
## Disclaimer
SquashInfo is a valuable resource for the international squash community. By creating and sharing this package, I do not intend to compete with SquashInfo or any of its stakeholders. The `squashinformr` package was created to allow individuals to access data from SquashInfo in an efficient and responsible way, using <a href="https://github.com/dmi3kno/polite" target="_blank">`polite` principles</a>. Following `polite` principles incurs mandatory delays on the scraping process set by SquashInfo. This prevents the use of this package from incurring unnecessary harm to SquashInfo servers via overwhelming requests. Therefore, it is important that users are patient when using this package. SquashInfo currently offers full access to their data and extra features through a premium membership. Please consider <a href="http://www.squashinfo.com/upgrade" target="_blank">signing up and subscribing</a> to SquashInfo to support their work.
## Author
This package was authored by Hayden MacDonald. Feel free to email me at hmd[at]needleinthehay.ca.
## License
The `squashinformr` package is released under a <a href="https://github.com/HaydenMacDonald/squashinformr/blob/main/LICENSE.md" target="_blank">GPL-3</a> license.