-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathREADME.Rmd
189 lines (132 loc) · 5.08 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
---
output:
md_document:
variant: gfm
toc: true
toc_depth: 2
---
<img src='man/figures/logo.png' align="right" height="139" />
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
```{r, echo = FALSE}
# Remove scientific notation
options(scipen = 999)
```
# rfutbin
R package to get price and stats of FIFA Ultimate Team players in [Futbin](https://www.futbin.com) for all platforms (PS4/XBox One/PC).
## Installation
This package is available only on GitHub. To install it, use the `devtools` package:
```{r eval = FALSE}
library(devtools)
install_github("danielredondo/rfutbin")
library(rfutbin)
```
## Examples
#### Load package
```{r}
library(rfutbin)
```
#### Search for a player
```{r}
futbin_search(name = "Lionel Messi")
```
```{r, echo = FALSE, results='hide'}
Sys.sleep(3)
```
#### The default platform is PS4, but you can get the price in other platforms (XBox One/PC)
```{r}
futbin_search(name = "Lionel Messi", platform = "xone")
futbin_search(name = "Lionel Messi", platform = "pc")
```
```{r, echo = FALSE, results='hide'}
Sys.sleep(3)
```
#### Search for more than one player
```{r}
futbin_search(name = c("Lionel Messi", "Cristiano Ronaldo"))
```
```{r, echo = FALSE, results='hide'}
Sys.sleep(3)
```
#### Search for a specific version of a player
```{r}
# Lewandowski rare card
futbin_search(name = "Lewandowski", version = "Rare")
```
```{r, echo = FALSE, results='hide'}
Sys.sleep(3)
```
```{r}
# Luis Suarez One to watch (OTW)
futbin_search(name = "Luis Suarez", version = "OTW")
```
```{r, echo = FALSE, results='hide'}
Sys.sleep(3)
```
```{r}
# Grealish In-Form (IF) showing verbose
futbin_search(name = "Grealish", version = "IF", verbose = TRUE)
```
```{r, echo = FALSE, results='hide'}
Sys.sleep(3)
```
#### Download all players from a Futbin webpage
```{r}
# All Aston Villa players -> To get the URL, go to futbin.com/players and filter
aston_villa <- futbin_scrap(url = "https://www.futbin.com/players?page=1&club=2")
head(aston_villa)
```
```{r, echo = FALSE, results='hide'}
Sys.sleep(3)
```
```{r}
# All English players in Bundesliga -> To get the URL, go to futbin.com/players and filter
futbin_scrap(url = "https://www.futbin.com/21/players?page=1&league=19&nation=14")
```
```{r, echo = FALSE, results='hide'}
Sys.sleep(3)
```
#### Radar plot comparing Van Dijk and Messi
```{r, eval = FALSE}
players <- futbin_search(name = c("Van Dijk", "Lionel Messi"), version = "Rare")
futbin_plot(players)
```
![https://i.imgur.com/MP9cmAk.png](https://i.imgur.com/MP9cmAk.png)
*(Please note that this is a static version. Real plots are interactive.)*
#### Radar plot comparing goalkeepers:
```{r, eval = FALSE}
some_goalkeepers <- futbin_search(name = c("De Gea", "Kepa", "Hugo Lloris"), version = "Rare")
futbin_plot(some_goalkeepers, gk = TRUE)
```
![https://i.imgur.com/zpD21wa.png](https://i.imgur.com/zpD21wa.png)
*(Please note that this is a static version. Real plots are interactive.)*
## Functions
### futbin_search
`futbin_search` searchs players in Futbin. It has the following parameters:
- `name`. Optional. Vector with the names of the players. If not specified, it will report the 30 highest-rated players of the game.
- `platform`. Platform to get the prices from. Default is `ps4`. Other options are `xone` (XBox One) and `pc`.
- `version`. Optional. Version of the cards. Some options are "Rare", "Non-Rare", "IF" (In-Form), "SIF" (Second In-Form), ...
- `verbose`. Optional. To show additional messages (webpage scraped and number of players found).
The output of the function is a dataframe with all the players found searching for `name` and `version`.
### futbin_scrap
`futbin_scrap` extracts all players of a Futbin URL. It has the following parameters:
- `url`. Futbin URL to web scrap. Futbin webpage (https://www.futbin.com/players) can be used to make customised filters, and then copy the URL here. All the players found in the URL (and the next pages) will be automatically detected and downloaded.
- `platform`. Platform to get the prices from. Default is `ps4`. Other options are `xone` (XBox One) and `pc`.
- `sleep_time`. Time (in seconds) ellapsed between scraping one page and the next one. Please respect Futbin API.
- `verbose`. Optional. To show additional verbose about webpage used and number of players found.
The output of the function is a dataframe with all the players found at the URL.
### futbin_plot
`futbin_plot` makes an interactive radar plot of the stats of the players. It has the following parameters:
- `df` dataframe generated with columns `pac`, `sho`, `pas`, `dri`, `def`, `phy`. This dataframe can be obtained from function `futbin_search`.
- `gk` Optional. If `TRUE`, the labels of the plot are the main stats for goalkeepers: diving, handling, kicking, reflexes, speed and position.
The output of the function is an interactive radar plot of the stats.
## Citation
If you use this package, you can cite it as:
```
Redondo-Sanchez, Daniel (2021). rfutbin (v1.0.2): R package to get price and stats of FIFA Ultimate Team players in Futbin. https://github.com/danielredondo/rfutbin
```