-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
104 lines (74 loc) · 3.07 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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# fplboard <img src="inst/app/www/logo.png" align="right" width="120"/>
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![Codecov test coverage](https://codecov.io/gh/thomaszwagerman/fplboard/branch/main/graph/badge.svg)](https://app.codecov.io/gh/thomaszwagerman/fplboard?branch=main)
[![R-CMD-check](https://github.com/thomaszwagerman/fplboard/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/thomaszwagerman/fplboard/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
The goal of fplboard is to create a dashboard to easily extract useful information from the FPL API.
This dashboard is built on top of [fplscrapR](https://github.com/wiscostret/fplscrapR), but also has its own native functions.
fplboard is built in a modular way using the golem framework. Each module has its own functionality and is an individual menu item, meaning features will be added to this package slowly over time.
## Installation
You can install the development version of fplboard like so:
``` r
remotes::install_github("thomaszwagerman/fplboard")
library(fplboard)
```
If you want to run the app locally, all you need to do is:
```r
devtools::load_all()
run_app()
```
## Examples
This is a basic example which shows a function that return expected points table for a given team.
Under the hood it relies on `fplscrapR`'s `get_entry_player_picks()` and `get_player_info()` functions.
Let's have a look at the table:
```{r example, echo = FALSE, message = FALSE, warning = FALSE, eval = FALSE}
library(fplboard)
library(knitr)
benchwarmers <- get_ep_for_entrant(entrant_number = 9680, gameweek = get_current_gw_number())
benchwarmers <- benchwarmers |>
dplyr::select(.data$team_code, .data$photo,
"Player" = .data$playername,
"Expected Points" = .data$ep_next,
"Selected by (%)" = .data$selected_by_percent) |>
gt::gt() |>
gtExtras::gt_img_rows(.data$photo, img_source = "web") |>
gtExtras::gt_img_rows(.data$team_code, img_source = "web") |>
gt::cols_label(
team_code = "",
photo = ""
) |>
gt::tab_row_group(
label = "Bench",
rows = c(12:15)
) |>
gt::tab_row_group(
label = "Starting 11",
rows = c(1:11)
)
```
<p align="center"><img src="man/figures/benchwarmer_table.png"></p>
Another bit of functionality is plotting minileague point over time, using `fplscrapR::get_league_entries()` information:
``` {r point_plot, fig.height = 8, fig.width = 16, echo = FALSE, warning = FALSE}
library(fplboard)
library(ggplot2)
plot_league_points(570437)
```
Or by rank for each gameweek:
``` {r ranked_plot, fig.height = 8, fig.width = 16, echo = FALSE, warning = FALSE}
library(fplboard)
library(ggplot2)
plot_league_standings(570437)
```