OKay here is a start to our app.
Ignore the "Opportunity Breakdown" tab for now. I'm having some issue with getting the plot I want. It works in the console but not the app for some reason. The code is kinda ugly, but it works. Not too proficient in R, usually use python. I haven't used R outside of basic visualizations since grad school (r1 phd program couldn't afford SAS because cheap) about 15 years ago so just a little rusty. We will get better and make it nicer/optimize code/etc but we can start here.
Known issues:
When you select two players who never had a H2H together it will display blank names for both
If you remove the number from running average value the graph goes weird.
Data:
Here's the data for only neutral faceoffs with the pre-season and all star game removed
http://crowdsourcesyndicate.info/NHL/faceoffNeutral.csv
For R Shiny, download R Studio or whatever you use. Create a new shiny project and you need 3 files. global.R (this is actually optional, but good to use), server.R, ui.R
Here's global.R:
https://pastebin.com/wgLyBDUE
server.R:
https://pastebin.com/6syPksMz
ui.R:
https://pastebin.com/8yNvKNnT
When you run the app it should look like this
Variables on the sidebar:
Select a player: This will display data for this person
Opponent: Only used in the "Historical H2H" tab
Team: Only used in "Team Data" tab
Date Range: Used for all data. I set the default for 2 years from the current day
Running average value: Used for the player running faceoff win %. Default is last 30 faceoffs but you can adjust the number.
Player Data -> Data is what is on the front screen. Provides a summary across five subsets (All, Home, Away, vs. L, vs. R) for the player on the top. Then the raw data on the bottom.
Player Data -> Running Average. This will produce a time series graph of faceoff win% with the rolling mean size set by the box in the bottom left.
You can see it adheres to the date range we selected. Chart title updates to reflect the variables we chose.
Player Data -> Historical H2H. Pick 2 skaters and it will tell you how many times they faced off and give you summary statistics.
Same. Adheres to the date range
Team Data -> Team Comparison. Can see if certain teams are better at faceoffs (coaching?)
Team Data -> Opportunity Breakdown. This is a little broken right now. My envision was just a box plot based on the team selected of who on the team gets the faceoffs. Could be good for predicting who might be getting the faceoff to start the game.
Calculate H2H Line -> Doesn't work yet but we can add this once we develop our model.
Things to add: Dashed line on running average which is their average over the time
What about an "ignore bubble" button. Looking at that Auston Matthews graph shows he turned a disaster post bubble. That data could be misleading because they were trapped in Orlando florida or wherever for months and the depression caused by that could have hurt him.
What else?
Last edited by fkjlhfdkjhkj.; 12-27-2020 at 06:08 PM.