-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.Rmd
169 lines (133 loc) · 7.63 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
# recruitR <a href='https://recruitR.sportsdataverse.org/'><img src='https://raw.githubusercontent.com/sportsdataverse/recruitR/main/logo.png' align="right" width="30%" min-width="100px" /></a>
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg?style=for-the-badge)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![Version-Number](https://img.shields.io/github/r-package/v/sportsdataverse/recruitR?label=recruitR&logo=R&logoColor=white&style=for-the-badge)](https://github.com/sportsdataverse/recruitR) [![R-CMD-check](https://img.shields.io/github/workflow/status/sportsdataverse/recruitR/R-CMD-check?label=R-CMD-Check&logo=R&logoColor=white&style=for-the-badge)](https://github.com/sportsdataverse/recruitR/actions/workflows/R-CMD-check.yaml)
![Contributors](https://img.shields.io/github/contributors/sportsdataverse/recruitR?style=for-the-badge)
[![Twitter Follow](https://img.shields.io/twitter/follow/saiemgilani?color=blue&label=%40saiemgilani&logo=twitter&style=for-the-badge)](https://twitter.com/saiemgilani)
<!-- badges: end -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
A college football recruiting package
`recruitR` is an R package for working with college sports recruiting data. It is an R API wrapper around [collegefootballdata's](https://collegefootballdata.com/) recruiting and roster endpoints.
__Note:__ For details on the data sources, please go the website linked above. Sometimes there are inconsistencies in the underlying data itself. Please report issues here or to [https://collegefootballdata.com/](https://collegefootballdata.com/).
## Installation
You can install the released version of [**`recruitR`**](https://github.com/sportsdataverse/recruitR) from [GitHub](https://github.com/sportsdataverse/recruitR) with:
```r
# You can install using the pacman package using the following code:
if (!requireNamespace('pacman', quietly = TRUE)){
install.packages('pacman')
}
pacman::p_load_current_gh("sportsdataverse/recruitR")
```
```r
# if you would prefer devtools installation
if (!requireNamespace('devtools', quietly = TRUE)){
install.packages('devtools')
}
# Alternatively, using the devtools package:
devtools::install_github(repo = "sportsdataverse/recruitR")
```
## Offensive Tackle Example
```{r examplerdm, message=FALSE, warning=FALSE, results='hide'}
library(recruitR)
library(dplyr)
library(ggplot2)
```
Let's say that we are interested in seeing how many offensive tackles in the 2020 recruiting cycle were:
- located in Florida
- located in the states bordering Florida
- ranked inside the top 1000
```{r OTs, message=FALSE, warning=FALSE}
FL_OTs <- cfbd_recruiting_player(2020, recruit_type = 'HighSchool', state='FL', position ='OT')
GA_OTs <- cfbd_recruiting_player(2020, recruit_type = 'HighSchool', state='GA', position ='OT')
AL_OTs <- cfbd_recruiting_player(2020, recruit_type = 'HighSchool', state='AL', position ='OT')
SE_OTs <- dplyr::bind_rows(FL_OTs, GA_OTs, AL_OTs)
SE_OTs_1k <- SE_OTs %>%
dplyr::filter(ranking < 1000) %>%
dplyr::arrange(ranking)
SE_OTs_1k %>%
dplyr::select(ranking, name, school, committed_to, position,
height, weight, stars, rating, city, state_province)
```
## Plotting the Offensive Tackles by State
You can also create a plot:
```{r plot_OTs, message=FALSE, warning=FALSE}
SE_OTs_1k$stars <- factor(SE_OTs_1k$stars,levels = c(5,4,3,2))
SE_OTs_1k_grp <- SE_OTs_1k %>%
dplyr::group_by(state_province, stars) %>%
dplyr::summarize(players = n()) %>%
dplyr::ungroup()
ggplot(SE_OTs_1k_grp ,aes(x = state_province, y = players, fill = factor(stars))) +
geom_bar(stat = "identity",colour='black') +
xlab("State") + ylab("Number of Players") +
labs(title="Top-1000 Offensive Tackles in FL, GA, and AL - Class of 2020",
subtitle="Figure: @SaiemGilani | Data: @CFB_data with #recruitR")+
geom_text(aes(label = players),size = 4, position = position_stack(vjust = 0.5))+
scale_fill_manual(values=c("dodgerblue2","lightskyblue","red3","ghostwhite"))+
theme(legend.title = element_blank(),
legend.text = element_text(size = 12, margin=margin(t=0.2,r=0,b=0.2,l=-1.2,unit=c("mm")),
family = "serif"),
legend.background = element_rect(fill = "grey99"),
legend.key.width = unit(.2,"cm"),
legend.key.size = unit(.3,"cm"),
legend.position = c(0.25, 0.84),
legend.margin=margin(t = 0.4,b = 0.4,l=-1.2,r=0.4,unit=c('mm')),
legend.direction = "horizontal",
legend.box.background = element_rect(colour = "#500f1b"),
axis.title.x = element_text(size = 12, margin = margin(0,0,1,0,unit=c("mm")),
family = "serif",face="bold"),
axis.text.x = element_text(size = 10, margin=margin(0,0,1,0,unit=c("mm")),
family = "serif"),
axis.title.y = element_text(size = 12, margin = margin(0,0,0,0,unit=c("mm")),
family = "serif",face="bold"),
axis.text.y = element_text(size = 12, margin = margin(1,1,1,1,unit=c("mm")),
family = "serif"),
plot.title = element_text(size = 14, margin = margin(t=0,r=0,b=1.5,l=0,unit=c("mm")),
lineheight=-0.5, family = "serif",face="bold"),
plot.subtitle = element_text(size = 12, margin = margin(t=0,r=0,b=2,l=0,unit=c("mm")),
lineheight=-0.5, family = "serif"),
plot.caption = element_text(size = 12, margin=margin(t=0,r=0,b=0,l=0,unit=c("mm")),
lineheight=-0.5, family = "serif"),
strip.text = element_text(size = 10, family = "serif",face="bold"),
panel.background = element_rect(fill = "grey95"),
plot.background = element_rect(fill = "grey85"),
plot.margin=unit(c(top=0.4,right=0.4,bottom=0.4,left=0.4),"cm"))
```
## **Documentation**
For more information on the package and function reference, please see
the [**`recruitR`** documentation
website](https://recruitR.sportsdataverse.org).
## **Breaking Changes**
[**Full News on
Releases**](https://recruitR.sportsdataverse.org/news/index.html)
## Follow the [SportsDataverse](https://twitter.com/SportsDataverse) on Twitter and star this repo
[![Twitter
Follow](https://img.shields.io/twitter/follow/SportsDataverse?color=blue&label=%40SportsDataverse&logo=twitter&style=for-the-badge)](https://twitter.com/SportsDataverse)
[![GitHub
stars](https://img.shields.io/github/stars/sportsdataverse/recruitR.svg?color=eee&logo=github&style=for-the-badge&label=Star%20recruitR&maxAge=2592000)](https://github.com/sportsdataverse/recruitR/stargazers/)
## **Our Authors**
- [Saiem Gilani](https://twitter.com/saiemgilani)
<a href="https://twitter.com/saiemgilani" target="blank"><img src="https://img.shields.io/twitter/follow/saiemgilani?color=blue&label=%40saiemgilani&logo=twitter&style=for-the-badge" alt="@saiemgilani" /></a>
<a href="https://github.com/saiemgilani" target="blank"><img src="https://img.shields.io/github/followers/saiemgilani?color=eee&logo=Github&style=for-the-badge" alt="@saiemgilani" /></a>
## **Citations**
To cite the [**`cfbfastR`**](https://cfbfastR.sportsdataverse.org/) R
package in publications, use:
BibTex Citation
``` bibtex
@misc{gilani_2021_recruitr,
author = {Gilani, Saiem},
title = {recruitR: The SportsDataverse's R Package for College Sports Recruiting Data.},
url = {https://recruitR.sportsdataverse.org/},
year = {2021}
}
```