-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoilersflames.Rmd
61 lines (50 loc) · 1.42 KB
/
oilersflames.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
---
title: "Andy vs Adam 2016-2017"
output: html_document
runtime: shiny
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(ggplot2)
library(curl)
# helper functions
source('util.R')
# setup auth
h <- new_handle()
handle_setheaders(h, "Authorization" = "Basic YW5keWN6ZXJ3b25rYTpwb2xvbmlh")
#team data
teams <- read.csv(curl("https://www.mysportsfeeds.com/api/feed/pull/nhl/2016-2017/conference_team_standings.csv", handle = h))
teams <- subset(
teams[, c(5,6,8,9,10,12,13,25)],
X.Team.Name == "Oilers" | X.Team.Name == "Flames"
)
teams <- teams[order(teams$X.Team.Name, decreasing=TRUE),]
# create a new table with Andy & Adam rows
totalPoints <- teams[, 7] + teams[, 8]
betStats <- data.frame(
Who = c("Andy","Adam"),
Team = teams[, 2],
Team.Games = teams[, 3],
Team.Record = teamRecord(teams[, 4], teams[, 5], teams[, 6]),
Team.Points = teams[, 7],
Team.Goals = teams[, 8],
Bet = totalPoints
)
```
### Rules
1. Oilers v Flames Total Points
2. Oilers v Flames Total Goals
Add 'em up at the end of the year and $10/pt up to $100.
## Stats
```{r table, echo=FALSE}
renderTable(betStats)
```
```{r team, echo=FALSE}
renderPlot({
ggplot(data=betStats, aes(x=Team, y=Team.Points, fill=Team)) + geom_bar(stat="identity")
})
renderPlot({
ggplot(data=betStats, aes(x=Team, y=Team.Goals, fill=Team)) + geom_bar(stat="identity")
})
```
Stats provided by [MySportsFeeds](https://www.mysportsfeeds.com/)