This application demonstrates various features of R & Shiny development.
This package is currently private only. If you have been given access on GitHub please follow the instructions below:
devtools::install_github("James-G-Hill/shiny-app-nba")
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
You may be able to see the application at the following webpage:
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.
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:
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:
golem::run_dev()
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 teamseason
: A season in the format: ‘yyyy - yyyy’team_color_1
: A team hex color for the bannerteam_color_2
: Another team hex color for the banner
Team colors can be found at the following link:
- Create an account at ‘www.shinyapps.io’
- Install ‘rsconnect’ package (
install.packages('rsconnect')
) - Follow the instructions for authorizing an account
- Load the library ‘rsconnect’ locally (
library('rsconnect')
) - Deploy with
rsconnect::deployApp('path/to/your/app')
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 theesquisse
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:
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.
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.
The esquisse
package interactive chart doesn’t work on tested iPad.
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: