-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.Rmd
508 lines (457 loc) · 21.5 KB
/
index.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
---
title: "Standings Tracker"
date: "Updated October 21, 2023"
output:
flexdashboard::flex_dashboard:
social: [ "twitter", "facebook"]
source_code: "https://github.com/joelrip/StandingsTracker"
orientation: rows
vertical_layout: fill
---
<style type="text/css">
.intro { /* intro */
font-size: 16px;
padding-left:10px;
</style>
<p class="intro">Tracking US club soccer standings, game by game. See the "About" page for more info!</p>
```{r setup, include=FALSE}
library(flexdashboard)
library(highcharter)
###USL League One
USLOnePointsLong = read.csv("USLOnePointsLong.csv", stringsAsFactors = F)
#Turn playoff thresholds into a list for graphing
thresholdsUSL1E = list_parse2(USLOnePointsLong[which(USLOnePointsLong$Teams == "Thresholds" & USLOnePointsLong$Conference == "East"), c(2,10,11)])
thresholdBottomUSL1E = list_parse2(USLOnePointsLong[which(USLOnePointsLong$Teams == "Thresholds" & USLOnePointsLong$Conference == "East"), c(2,10)])
for (item in 1:length(thresholdBottomUSL1E)) {
thresholdBottomUSL1E[[item]][[3]] = -100
}
#Turn PointsLessGames into a list for graphing
USLOneSeries = list()
for (item in unique(USLOnePointsLong$Teams[which(USLOnePointsLong$Teams != "Thresholds" & USLOnePointsLong$Conference == "East")])) {
USLOneSeries = c(USLOneSeries, list(list(name = item,
data = USLOnePointsLong$PointsLessGames[which(USLOnePointsLong$Teams == item)],
marker = list(enabled = F))))
}
###USL Championship
USLPointsLong = read.csv("USLPointsLong.csv", stringsAsFactors = F)
#Turn playoff thresholds into a list for graphing
thresholdsUSLW = list_parse2(USLPointsLong[which(USLPointsLong$Teams == "Thresholds" & USLPointsLong$Conference == "West"), c(2,10,11)])
thresholdBottomUSLW = list_parse2(USLPointsLong[which(USLPointsLong$Teams == "Thresholds" & USLPointsLong$Conference == "West"), c(2,10)])
for (item in 1:length(thresholdBottomUSLW)) {
thresholdBottomUSLW[[item]][[3]] = -100
}
thresholdsUSLE = list_parse2(USLPointsLong[which(USLPointsLong$Teams == "Thresholds" & USLPointsLong$Conference == "East"), c(2,10,11)])
thresholdBottomUSLE = list_parse2(USLPointsLong[which(USLPointsLong$Teams == "Thresholds" & USLPointsLong$Conference == "East"), c(2,10)])
for (item in 1:length(thresholdBottomUSLE)) {
thresholdBottomUSLE[[item]][[3]] = -100
}
#Turn PointsLessGames into a list for graphing
USLWestSeries = list()
for (item in unique(USLPointsLong$Teams[which(USLPointsLong$Teams != "Thresholds" & USLPointsLong$Conference == "West")])) {
USLWestSeries = c(USLWestSeries, list(list(name = item,
data = USLPointsLong$PointsLessGames[which(USLPointsLong$Teams == item)],
marker = list(enabled = F))))
}
USLEastSeries = list()
for (item in unique(USLPointsLong$Teams[which(USLPointsLong$Teams != "Thresholds" & USLPointsLong$Conference == "East")])) {
USLEastSeries = c(USLEastSeries, list(list(name = item,
data = USLPointsLong$PointsLessGames[which(USLPointsLong$Teams == item)],
marker = list(enabled = F))))
}
###MLS
MLSPointsLong = read.csv("MLSPointsLong.csv", stringsAsFactors = F)
#Turn playoff thresholds into a list for graphing
thresholdsMLSW = list_parse2(MLSPointsLong[which(MLSPointsLong$Teams == "Thresholds" & MLSPointsLong$Conference == "West"), c(2,10,11)])
thresholdBottomMLSW = list_parse2(MLSPointsLong[which(MLSPointsLong$Teams == "Thresholds" & MLSPointsLong$Conference == "West"), c(2,10)])
for (item in 1:length(thresholdBottomMLSW)) {
thresholdBottomMLSW[[item]][[3]] = -100
}
thresholdsMLSE = list_parse2(MLSPointsLong[which(MLSPointsLong$Teams == "Thresholds" & MLSPointsLong$Conference == "East"), c(2,10,11)])
thresholdBottomMLSE = list_parse2(MLSPointsLong[which(MLSPointsLong$Teams == "Thresholds" & MLSPointsLong$Conference == "East"), c(2,10)])
for (item in 1:length(thresholdBottomMLSE)) {
thresholdBottomMLSE[[item]][[3]] = -100
}
#Turn PointsLessGames into a list for graphing
MLSWestSeries = list()
for (item in unique(MLSPointsLong$Teams[which(MLSPointsLong$Teams != "Thresholds" & MLSPointsLong$Conference == "West")])) {
MLSWestSeries = c(MLSWestSeries, list(list(name = item,
data = MLSPointsLong$PointsLessGames[which(MLSPointsLong$Teams == item)],
marker = list(enabled = F))))
}
MLSEastSeries = list()
for (item in unique(MLSPointsLong$Teams[which(MLSPointsLong$Teams != "Thresholds" & MLSPointsLong$Conference == "East")])) {
MLSEastSeries = c(MLSEastSeries, list(list(name = item,
data = MLSPointsLong$PointsLessGames[which(MLSPointsLong$Teams == item)],
marker = list(enabled = F))))
}
###Assign team colors to all teams
cols = c("Atlanta United FC" = "#80000A",
"Austin" = "#00B140",
"Charlotte" = "#1A85C8",
"Chicago Fire" = "#C2002F",
"Colorado Rapids" = "#862633",
"Columbus Crew" = "#FFF200",
"DC United" = "#231F20",
"FC Cincinnati" = "#F05323",
"FC Dallas" = "#003E7E",
"Houston Dynamo" = "#F4911E",
"Inter Miami" = "#F7B5CD",
"Los Angeles FC" = "#C39E6D",
"Los Angeles Galaxy" = "#FFD200",
"Minnesota United FC" = "#8CD2F4",
"Montreal Impact" = "#2B63AD",
"Nashville SC" = "#ECE83A",
"New England Revolution" = "#E51938",
"New York City FC" = "#6CACE4",
"New York Red Bulls" = "#E31351",
"Orlando City SC" = "#61259E",
"Philadelphia Union" = "#002D55",
"Portland Timbers" = "#00482B",
"Real Salt Lake" = "#B30838",
"San Jose Earthquakes" = "#221F1F",
"Seattle Sounders" = "#658D1B",
"Sporting Kansas City" = "#93B1D7",
"St. Louis City" = "#E0004D",
"Toronto FC" = "#AB1E2D",
"Vancouver Whitecaps" = "#94C2E4",
"Birmingham Legion" = "#9F8A59",
"Charleston Battery" = "#FDCA00",
"Colorado Springs" = "#09305D",
"Detroit City" = "#3F2021",
"El Paso Locomotive" = "#73B3E6",
"Hartford Athletic" = "#009845",
"Indy Eleven" = "#CF1C2B",
"Las Vegas Lights" = "#00BDEF",
"Loudoun United" = "#000000",
"Louisville City" = "#532B78",
"Memphis 901" = "#D31245",
"Miami FC" = "#F03E1E",
"Monterey Bay" = "#67D2DF",
"New Mexico United" = "#FFF000",
"Oakland Roots" = "#00BB7E",
"Orange County SC" = "#EF3432",
"Phoenix Rising" = "#EB1921",
"Pittsburgh Riverhounds" = "#FFC629",
"Rio Grande Valley" = "#EE351E",
"Sacramento Republic" = "#8B0F04",
"San Antonio" = "#161113",
"San Diego Loyal" = "#148F8C",
"Tampa Bay Rowdies" = "#4A8B2C",
"FC Tulsa" = "#BD9B60",
"Central Valley Fuego" = "#64A70B",
"Charlotte Independence" = "#003DA5",
"Chattanooga Red Wolves" = "#7C2629",
"Forward Madison" = "#71C5E8",
"Greenville Triumph" = "#97D700",
"Lexington" = "#44D62C",
"North Carolina" = "#01426A",
"Northern Colorado" = "#BD9B60",
"One Knoxville" = "#E56A54",
"Richmond Kickers" = "#C8102E",
"Tormenta" = "#8D9093",
"Union Omaha" = "#010101"
)
MLSWest = unique(MLSPointsLong$Teams[which(MLSPointsLong$Teams != "Thresholds" & MLSPointsLong$Conference == "West")])
MLSWestCols = unname(cols[grep(paste(MLSWest, collapse = "|"), names(cols))])
MLSEast = unique(MLSPointsLong$Teams[which(MLSPointsLong$Teams != "Thresholds" & MLSPointsLong$Conference == "East")])
MLSEastCols = unname(cols[grep(paste(MLSEast, collapse = "|"), names(cols))])
USLWest = unique(USLPointsLong$Teams[which(USLPointsLong$Teams != "Thresholds" & USLPointsLong$Conference == "West")])
USLWestCols = unname(cols[grep(paste(USLWest, collapse = "|"), names(cols))])
USLEast = unique(USLPointsLong$Teams[which(USLPointsLong$Teams != "Thresholds" & USLPointsLong$Conference == "East")])
USLEastCols = unname(cols[grep(paste(USLEast, collapse = "|"), names(cols))])
USLOne = unique(USLOnePointsLong$Teams[which(USLOnePointsLong$Teams != "Thresholds" & USLOnePointsLong$Conference == "East")])
USLOneCols = unname(cols[grep(paste(USLOne, collapse = "|"), names(cols))])
###Chart parameters
chartMax = 35
chartMin = -15
labelX = 34
labelYUp = 32
labelYDown = -14
```
MLS
=====================================
Row
-----------------------------------------------------------------------
### <strong>MLS Western Conference</strong>
```{r}
highchart() %>%
hc_add_series(name = "middle", type = "arearange", lineWidth = 0, showInLegend = F, color = "#f2f2f2",
marker = list(enabled = FALSE), data = thresholdsMLSW, enableMouseTracking = F) %>%
hc_add_series(name = "bottom", type = "arearange", lineWidth = 0, showInLegend = F, color = "#bbbbbb",
marker = list(enabled = FALSE), data = thresholdBottomMLSW, enableMouseTracking = F) %>%
hc_add_series_list(MLSWestSeries) %>%
hc_colors(MLSWestCols) %>%
hc_yAxis(title = list(text = "Points Minus Games Played"),
max = chartMax, min = chartMin,
endOnTick = F) %>%
hc_xAxis(title = list(text = "Game")) %>%
hc_annotations(
list(
labelOptions = list(x = 0, y = 0,
backgroundColor = "rgba(255, 255, 255, 0)",
borderColor = "rgba(255, 255, 255, 0)")
,
labels = list( #UNCOMMENT WHEN CLINCHED AND ELIMINATED AREAS APPEAR ON THE CHARTS
list(
point = list(
x = labelX,
y = labelYUp,
xAxis = 0,
yAxis = 0
),
text = "Clinched<br/>Playoffs"
),
list(
point = list(
x = labelX,
y = labelYDown,
xAxis = 0,
yAxis = 0
),
text = "Mathematically<br/>Eliminated"
)
)
)) %>%
hc_legend(align = "right", verticalAlign = "middle", layout = "vertical") %>%
hc_tooltip(crosshairs = T, backgroundColor = "#fcffc5", shared = T,
formatter = JS("function() {
var s = '<strong>Game '+ this.x +'</strong>';
var sortedPoints = this.points.sort(function(a, b){
return ((a.y > b.y) ? -1 : ((a.y < b.y) ? 1 : 0));
});
$.each(sortedPoints , function(i, point) {
s += '<br/>'+ point.series.name +': '+ point.y;
});
return s;
}")
)
```
### <strong>MLS Eastern Conference</strong>
```{r}
highchart() %>%
hc_add_series(name = "middle", type = "arearange", lineWidth = 0, showInLegend = F, color = "#f2f2f2",
marker = list(enabled = FALSE), data = thresholdsMLSE, enableMouseTracking = F) %>%
hc_add_series(name = "bottom", type = "arearange", lineWidth = 0, showInLegend = F, color = "#bbbbbb",
marker = list(enabled = FALSE), data = thresholdBottomMLSE, enableMouseTracking = F) %>%
hc_add_series_list(MLSEastSeries) %>%
hc_colors(MLSEastCols) %>%
hc_yAxis(title = list(text = "Points Minus Games Played"),
max = chartMax, min = chartMin,
endOnTick = F) %>%
hc_xAxis(title = list(text = "Game")) %>%
hc_annotations(
list(
labelOptions = list(x = 0, y = 0,
backgroundColor = "rgba(255, 255, 255, 0)",
borderColor = "rgba(255, 255, 255, 0)")
,
labels = list( #UNCOMMENT WHEN CLINCHED AND ELIMINATED AREAS APPEAR ON THE CHARTS
list(
point = list(
x = labelX,
y = labelYUp,
xAxis = 0,
yAxis = 0
),
text = "Clinched<br/>Playoffs"
),
list(
point = list(
x = labelX,
y = labelYDown,
xAxis = 0,
yAxis = 0
),
text = "Mathematically<br/>Eliminated"
)
)
)) %>%
hc_legend(align = "right", verticalAlign = "middle", layout = "vertical") %>%
hc_tooltip(crosshairs = T, backgroundColor = "#fcffc5", shared = T,
formatter = JS("function() {
var s = '<strong>Game '+ this.x +'</strong>';
var sortedPoints = this.points.sort(function(a, b){
return ((a.y > b.y) ? -1 : ((a.y < b.y) ? 1 : 0));
});
$.each(sortedPoints , function(i, point) {
s += '<br/>'+ point.series.name +': '+ point.y;
});
return s;
}")
)
```
USL Championship
=====================================
Row
-----------------------------------------------------------------------
### <strong>USL Championship Western Conference</strong>
```{r}
highchart() %>%
hc_add_series(name = "middle", type = "arearange", lineWidth = 0, showInLegend = F, color = "#f2f2f2",
marker = list(enabled = FALSE), data = thresholdsUSLW, enableMouseTracking = F) %>%
hc_add_series(name = "bottom", type = "arearange", lineWidth = 0, showInLegend = F, color = "#bbbbbb",
marker = list(enabled = FALSE), data = thresholdBottomUSLW, enableMouseTracking = F) %>%
hc_add_series_list(USLWestSeries) %>%
hc_colors(USLWestCols) %>%
hc_yAxis(title = list(text = "Points Minus Games Played"),
max = chartMax, min = chartMin,
endOnTick = F) %>%
hc_xAxis(title = list(text = "Game")) %>%
hc_annotations(
list(
labelOptions = list(x = 0, y = 0,
backgroundColor = "rgba(255, 255, 255, 0)",
borderColor = "rgba(255, 255, 255, 0)")
,
labels = list( #UNCOMMENT WHEN CLINCHED AND ELIMINATED AREAS APPEAR ON THE CHARTS
list(
point = list(
x = labelX,
y = labelYUp,
xAxis = 0,
yAxis = 0
),
text = "Clinched<br/>Playoffs"
),
list(
point = list(
x = labelX,
y = labelYDown,
xAxis = 0,
yAxis = 0
),
text = "Mathematically<br/>Eliminated"
)
)
)) %>%
hc_legend(align = "right", verticalAlign = "middle", layout = "vertical") %>%
hc_tooltip(crosshairs = T, backgroundColor = "#fcffc5", shared = T,
formatter = JS("function() {
var s = '<strong>Game '+ this.x +'</strong>';
var sortedPoints = this.points.sort(function(a, b){
return ((a.y > b.y) ? -1 : ((a.y < b.y) ? 1 : 0));
});
$.each(sortedPoints , function(i, point) {
s += '<br/>'+ point.series.name +': '+ point.y;
});
return s;
}")
)
```
### <strong>USL Championship Eastern Conference</strong>
```{r}
highchart() %>%
hc_add_series(name = "middle", type = "arearange", lineWidth = 0, showInLegend = F, color = "#f2f2f2",
marker = list(enabled = FALSE), data = thresholdsUSLE, enableMouseTracking = F) %>%
hc_add_series(name = "bottom", type = "arearange", lineWidth = 0, showInLegend = F, color = "#bbbbbb",
marker = list(enabled = FALSE), data = thresholdBottomUSLE, enableMouseTracking = F) %>%
hc_add_series_list(USLEastSeries) %>%
hc_colors(USLEastCols) %>%
hc_yAxis(title = list(text = "Points Minus Games Played"),
max = chartMax, min = chartMin,
endOnTick = F) %>%
hc_xAxis(title = list(text = "Game")) %>%
hc_annotations(
list(
labelOptions = list(x = 0, y = 0,
backgroundColor = "rgba(255, 255, 255, 0)",
borderColor = "rgba(255, 255, 255, 0)")
,
labels = list( #UNCOMMENT WHEN CLINCHED AND ELIMINATED AREAS APPEAR ON THE CHARTS
list(
point = list(
x = labelX,
y = labelYUp,
xAxis = 0,
yAxis = 0
),
text = "Clinched<br/>Playoffs"
),
list(
point = list(
x = labelX,
y = labelYDown,
xAxis = 0,
yAxis = 0
),
text = "Mathematically<br/>Eliminated"
)
)
)) %>%
hc_legend(align = "right", verticalAlign = "middle", layout = "vertical") %>%
hc_tooltip(crosshairs = T, backgroundColor = "#fcffc5", shared = T,
formatter = JS("function() {
var s = '<strong>Game '+ this.x +'</strong>';
var sortedPoints = this.points.sort(function(a, b){
return ((a.y > b.y) ? -1 : ((a.y < b.y) ? 1 : 0));
});
$.each(sortedPoints , function(i, point) {
s += '<br/>'+ point.series.name +': '+ point.y;
});
return s;
}")
)
```
USL League One
=====================================
Row
-----------------------------------------------------------------------
### <strong>USL League One</strong>
```{r}
highchart() %>%
hc_add_series(name = "middle", type = "arearange", lineWidth = 0, showInLegend = F, color = "#f2f2f2",
marker = list(enabled = FALSE), data = thresholdsUSL1E, enableMouseTracking = F) %>%
hc_add_series(name = "bottom", type = "arearange", lineWidth = 0, showInLegend = F, color = "#bbbbbb",
marker = list(enabled = FALSE), data = thresholdBottomUSL1E, enableMouseTracking = F) %>%
hc_add_series_list(USLOneSeries) %>%
hc_colors(USLOneCols) %>%
hc_yAxis(title = list(text = "Points Minus Games Played"),
max = chartMax, min = chartMin,
endOnTick = F) %>%
hc_xAxis(title = list(text = "Game")) %>%
hc_annotations(
list(
labelOptions = list(x = 0, y = 0,
backgroundColor = "rgba(255, 255, 255, 0)",
borderColor = "rgba(255, 255, 255, 0)")
,
labels = list( #UNCOMMENT WHEN CLINCHED AND ELIMINATED AREAS APPEAR ON THE CHARTS
list(
point = list(
x = 32,
y = labelYUp,
xAxis = 0,
yAxis = 0
),
text = "Clinched<br/>Playoffs"
),
list(
point = list(
x = 32,
y = labelYDown,
xAxis = 0,
yAxis = 0
),
text = "Mathematically<br/>Eliminated"
)
)
)) %>%
hc_legend(align = "right", verticalAlign = "middle", layout = "vertical") %>%
hc_tooltip(crosshairs = T, backgroundColor = "#fcffc5", shared = T,
formatter = JS("function() {
var s = '<strong>Game '+ this.x +'</strong>';
var sortedPoints = this.points.sort(function(a, b){
return ((a.y > b.y) ? -1 : ((a.y < b.y) ? 1 : 0));
});
$.each(sortedPoints , function(i, point) {
s += '<br/>'+ point.series.name +': '+ point.y;
});
return s;
}")
)
```
About
=====================================
<p><strong>Welcome!</strong> I built this interactive chart of <a href="http://www.mlssoccer.com/">MLS</a> and <a href="http://www.uslsoccer.com/">USL</a> standings after becoming frustrated with the fact that some teams had so many games in hand over other teams that the official standings became somewhat misleading. In the middle of the season, it's not uncommon for some teams to have played 5 or 6 more games than others as of a given date! It's less important how many points each team has on a given <strong>date</strong> than how many points they each have after playing a given number of <strong>games</strong>.
<p>So one thing these charts do is allow you to compare relative team standings after any given number of games. Just hover over a point in the charts, and you'll see the relative positions of all the teams when they had played that number of games. You can also remove a team from the chart by clicking its name in the legend, so you can see just the teams you want to see.
<p>But I have also made another, more experimental modification. Instead of showing the number of points each team has, the charts show the number of points <strong>minus the number of games played</strong>. Put another way, instead of 3 points for a win, 1 for a draw, and 0 for a loss, they show 2, 0, and -1 points respectively. This has the benefit of showing a team going <strong>down</strong> when they lose a game, staying level when they draw, and going up when they win, but without changing their relative positions. It's sort of like rotating the picture clockwise a bit. This way, if two teams have the same number of points, but one has played fewer games than the other, the team that has played fewer games is visually higher on the chart than the one that has played more games, giving what I think is a better representation of their relative positions in the standings. I hope you find it as useful as I do!