-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
153 lines (106 loc) · 5.04 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
---
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%"
)
```
# Shiny App with NBA Data
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
<!-- badges: end -->
This application demonstrates various features of R & Shiny development.
## Installation
This package is currently private only.
If you have been given access on GitHub please follow the instructions below:
```{r eval=FALSE}
devtools::install_github("James-G-Hill/shiny-app-nba")
```
## Features
Here is a list of notable features of the application:
- Written as R package with DESCRIPTION file & appropriate directory structure
- Written as a `golem` package with appropriate structure
- Written to `shiny` standards including shiny modules & reactive components
- Source control via Git
- Package management with `renv`
- 'Stats' page team & season variables managed with `config` file
- Added example test with `testthat`
- Added example `shinytest` script (although see related section below)
- Written to standards of Tidyverse Style Guide
- Documentation of functions with `roxygen2`
- GUI created with `bs4Dash` demonstrating BootStrap 4
- Interactive charts with `esquisse`
- Interactive tables with `DT`
- Chart created with `ggplot2`
- Themed with `fresh`
- Further detailed theming through custom `css`
- Added tooltips with `css`
- Added demonstration of calls to Javascript to switch tabs from Help tab
- Preloader configured with `waiter`
- Includes Rmarkdown to split, clean, & conform original data source
- Favicon created with `hexSticker`
## View the App
You may be able to see the application at the following webpage:
[Shiny NBA Free Throws](https://james-g-hill.shinyapps.io/shiny-app-nba/)
Note that I do not regularly check the app is still available.
It should work but it is possible that the service providers stops it.
If the link fails then please contact me so that I can restart it.
## Development Setup
In order to work on this application locally you will need the dataset.
First, you will need to download the dataset from the following link:
[NBA Free Throws](https://www.kaggle.com/sebastianmantey/nba-free-throws)
Then place the dataset in the 'dev/data/source_data' directory.
You will then need to open and run the `split_data.Rmd` script.
This will create the data in the 'dev/data/app_data' directory.
You can then test the app locally with the following command:
```{r eval=FALSE}
golem::run_dev()
```
## Changing Team & Season
The Stats tab has the team & season controlled by a configuration file.
This has been enabled to demonstrate the capability.
The file can be found at 'inst/golem-config.yml'.
The following options can be updated:
- `team` : A short code for the team
- `season` : A season in the format: 'yyyy - yyyy'
- `team_color_1` : A team hex color for the banner
- `team_color_2` : Another team hex color for the banner
Team colors can be found at the following link:
[NBA Team Colors](https://teamcolorcodes.com/nba-team-color-codes/)
## Running on shinyapps.io
1. Create an account at 'www.shinyapps.io'
2. Install 'rsconnect' package (`install.packages('rsconnect')`)
3. Follow the instructions for authorizing an account
4. Load the library 'rsconnect' locally (`library('rsconnect')`)
5. Deploy with `rsconnect::deployApp('path/to/your/app')`
## shinytest
I recorded a `shinytest` to demonstrate that I am capable of doing so.
However, recording this package & the tests with the finished package will fail.
There are 2 current issues which are beyond easy resolution:
- `phantomJS` won't record with the `esquisse` package loaded
- testing currently won't identify the `bs4Dash::sidebarMenu` id
The `phantomJS` issue maybe a result of that package no longer being developed.
The sidebarMenu 'id' issue seems like it should be resolved:
[bs4Dash Issue](https://github.com/RinteRface/bs4Dash/issues/8)
I was unable to get it to work even though the 'id' being available in app.
With further time I would investigate further & raise the second issue again.
## Further Development
This application was developed to demonstrate Shiny features.
I therefore did little development of the data due to time constraints.
A deep review of the data with full cleaning would be necessary with more time.
It is also not easy (& consistent) to identify the team for a player.
A list of players per team per season would allow for stats per team per game.
As is, the data only allows to analyse free throws across both teams per game.
This limits the strategic analysis possible.
## Known Issues
The `esquisse` package interactive chart doesn't work on tested iPad.
## Attribution
This package uses a free 'basketball' icon provided by Font Awesome.
The icon .svg file has been modified so the colour is white.
Please find the link to the license here:
https://fontawesome.com/license