-
Notifications
You must be signed in to change notification settings - Fork 1
/
.Rhistory
512 lines (512 loc) · 26.3 KB
/
.Rhistory
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
509
510
511
512
alpha = .5, shape=17)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = home.goals, color=home.goals),
alpha = .9) +
geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals, color = away.goals),
alpha = .5)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = home.goals, color=home.goals),
alpha = .9) +
geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
alpha = .5)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = home.goals, color=home.goals),
alpha = .9) + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
alpha = .5)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = home.goals, color=home.goals),
alpha = .9)
g <- ggplot() +
geom_polygon( data=MainStates, aes(x=long, y=lat, group=group),
color="lightgreen", fill="lightgreen" )
g
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
alpha = .5)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, size = home.goals, color=home.goals),
alpha = .9)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals, color=away.goals),
alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, size = home.goals, color=home.goals),
alpha = .9)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, size = home.goals, color=home.goals),
alpha = .9)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, size = home.goals),
alpha = .9)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, size = home.goals, color=home.goals),
color = 'red', alpha = .9)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
color='yellow',alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, size = home.goals, color=home.goals),
color = 'red', alpha = .9)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, size = home.goals, color=home.goals),
alpha = .9)
g <- ggplot() +
geom_polygon( data=MainStates, aes(x=long, y=lat, group=group),
color="lightyellow", fill="lightyellow" )
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, size = home.goals, color=home.goals),
alpha = .9)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals^2),
alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, size = home.goals, color=home.goals),
alpha = .9)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, size = home.goals, color=home.goals),
alpha = .9)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, color=home.goals),
alpha = .9)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, color=home.goals, shape=10),
alpha = .9)
View(arenaCities)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, color=home.goals),
alpha = .9)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, color=as.factor(home.goals)),
alpha = .9)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, color=home.goals),
alpha = .9)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals, color='yellow'),
alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, color=home.goals),
alpha = .9)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, color=home.goals),
alpha = .9)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
color='yellow',alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, color=home.goals),
alpha = .9)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
color='lightred',alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, color=home.goals),
alpha = .9)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, color=home.goals),
alpha = .9)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, color=home.goals),
color='blue',alpha = .9)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, color=home.goals),
alpha = .9)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_point() +geom_text(aes(x=long, y=lat, label=venue.name),hjust=0, vjust=0)
g + ggplot(data=arenaCities) geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point( aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_point(aes(x=long, y=lat, label=venue.name),hjust=0, vjust=0)
g + ggplot(data=arenaCities) + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point( aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_point(aes(x=long, y=lat, label=venue.name),hjust=0, vjust=0)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_point(data=arenaCities) +geom_text(aes(x=long, y=lat, label=venue.name),hjust=0, vjust=0)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_point(data=arenaCities, aes(x=long, y=lat, label=venue.name),hjust=0, vjust=0)
g + geom_point(data=arenaCities, aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(data=arenaCities, aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_point(data=arenaCities, aes(x=long, y=lat, label=venue.name))
g <- ggplot(data=arenaCities) +
geom_polygon( data=MainStates, aes(x=long, y=lat, group=group),
color="lightyellow", fill="lightyellow" )
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_point(data=arenaCities, aes(x=long, y=lat, label=venue.name))
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text(aes(x=long, y=lat, label=venue.name), hjust=0, vjust=0)
alpha = .9) + geom_text(aes(x=long, y=lat, label=ifelse(PTS>24,as.character(venue.name),''), hjust=0, vjust=0)
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text(aes(x=long, y=lat, label=ifelse(PTS>24,as.character(venue.name),'')), hjust=0, vjust=0)
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text(aes(x=long, y=lat, label=venue.name), hjust=0, vjust=0)
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text(aes(x=long, y=lat, label=name), hjust=0, vjust=0)
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text(aes(x=long, y=lat, label=county.etc), hjust=0, vjust=0)
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text(aes(x=long, y=lat, label=country.etc), hjust=0, vjust=0)
library(ggrepel)
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text_repel(aes(x=long, y=lat, label=name), hjust=0, vjust=0)
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text_repel(aes(x=long, y=lat, label=venue.name), hjust=0, vjust=0)
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text_repel(aes(x=long, y=lat, label=name), hjust=0, vjust=0)
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text_repel(aes(x=long, y=lat, label=name), hjust=0, vjust=0, size=10)
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text_repel(aes(x=long, y=lat, label=name), hjust=0, vjust=0, size=1)
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text_repel(aes(x=long, y=lat, label=name), hjust=0, vjust=0, size=2)
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text_repel(aes(x=long, y=lat, label=name), hjust=0, vjust=0, size=2.5)
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + scale_size_identity(trans="sqrt") + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text_repel(aes(x=long, y=lat, label=name), hjust=0, vjust=0, size=2.5)
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + scale_size_identity(trans="sqrt", guide='legend') + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text_repel(aes(x=long, y=lat, label=name), hjust=0, vjust=0, size=2.5)
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + scale_size_identity(trans="sqre", guide='legend') + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text_repel(aes(x=long, y=lat, label=name), hjust=0, vjust=0, size=2.5)
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + scale_size_identity(trans="sq", guide='legend') + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text_repel(aes(x=long, y=lat, label=name), hjust=0, vjust=0, size=2.5)
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + scale_size_identity(trans="exp", guide='legend') + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text_repel(aes(x=long, y=lat, label=name), hjust=0, vjust=0, size=2.5)
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + scale_size_identity(trans="sqrt", guide='legend') + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text_repel(aes(x=long, y=lat, label=name), hjust=0, vjust=0, size=2.5)
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + scale_size_identity(trans="log10", guide='legend') + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text_repel(aes(x=long, y=lat, label=name), hjust=0, vjust=0, size=2.5)
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + scale_size_identity(trans="asn", guide='legend') + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text_repel(aes(x=long, y=lat, label=name), hjust=0, vjust=0, size=2.5)
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + scale_size_identity(trans="hms", guide='legend') + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text_repel(aes(x=long, y=lat, label=name), hjust=0, vjust=0, size=2.5)
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text_repel(aes(x=long, y=lat, label=name), hjust=0, vjust=0, size=2.5)
runApp()
dataStatYear <- vF_game_info[vF_game_info$season == 2018]
df <- dataStatYear[,c('name','home.win','away.win','home.goals','away.goals')]
dfGroupByArena <- aggregate(. ~ name , df, sum)
colnames(dfGroupByArena)[1] <- 'venue.name'
dfGroupByArena <- merge(dfGroupByArena, vF_teams_DT[,c('venue.name', 'venue.city', 'locationName', 'division.name')], by = 'venue.name')
colnames(dfGroupByArena)[6] <- 'name'
us_cities <- us.cities
us_cities$name <- str_sub(us_cities$name, end = -4)
arenaCities <- merge(us_cities, dfGroupByArena, by = 'name')
MainStates <- map_data("state")
ggplot(data=arenaCities) +
geom_polygon( data=MainStates, aes(x=long, y=lat, group=group),
color="lightyellow", fill="lightyellow" ) +
geom_point(aes(x=long, y=lat, size = away.goals), color='violet',alpha = .5) +
geom_point(aes(x=long, y=lat, color= home.goals), alpha = .9) +
geom_text_repel(aes(x=long, y=lat, label=name), hjust=0, vjust=0, size=2.5)
runApp()
df <- dataStatYear[,c('name','home.win','away.win','home.goals','away.goals')]
dfGroupByArena <- aggregate(. ~ name , df, sum)
colnames(dfGroupByArena)[1] <- 'venue.name'
dfGroupByArena <- merge(dfGroupByArena, vF_teams_DT[,c('venue.name', 'venue.city', 'locationName', 'division.name')], by = 'venue.name')
colnames(dfGroupByArena)[6] <- 'name'
us_cities <- us.cities
us_cities$name <- str_sub(us_cities$name, end = -4)
arenaCities <- merge(us_cities, dfGroupByArena, by = 'name')
MainStates <- map_data("state")
ggplot(data=arenaCities) + geom_polygon( data=MainStates, aes(x=long, y=lat, group=group),
color="lightyellow", fill="lightyellow" ) + geom_point(aes(x=long, y=lat, size = away.win),
color='violet',alpha = .5) + geom_point(aes(x=long, y=lat, color= home.win),
alpha = .9) + geom_text_repel(aes(x=long, y=lat, label=name),
hjust=0, vjust=0, size=2.5)
g <- ggplot(data=arenaCities) +
geom_polygon( data=MainStates, aes(x=long, y=lat, group=group),
color="lightyellow", fill="lightyellow" )
g + geom_point(aes(x=long, y=lat, size = away.goals),
color='violet',alpha = .5) + geom_point(aes(x=long, y=lat, color=home.goals),
alpha = .9) + geom_text_repel(aes(x=long, y=lat, label=name), hjust=0, vjust=0, size=2.5)
us.cities$name[1:5]
dataStatYear <- vF_game_info[vF_game_info$season == 2018]
load("~/Desktop/Courses/EDAV/Ice-Hockey/data/2019-11-26_nhl-cleaned-data.RData")
dataStatYear <- vF_game_info[vF_game_info$season == 2018]
runApp()
dataStatYear <- vF_game_info[vF_game_info$season == 2018]
df <- dataStatYear[,c('name','home.win','away.win','home.goals','away.goals')]
dfGroupByArena <- aggregate(. ~ name , df, sum)
colnames(dfGroupByArena)[1] <- 'venue.name'
dfGroupByArena <- merge(dfGroupByArena, vF_teams_DT[,c('venue.name', 'venue.city', 'locationName', 'division.name')], by = 'venue.name')
colnames(dfGroupByArena)[6] <- 'name'
us_cities <- us.cities
us_cities$name <- str_sub(us_cities$name, end = -4)
arenaCities <- merge(us_cities, dfGroupByArena, by = 'name')
View(arenaCities)
runApp()
arenaCities %>% gather(key='GoalType', value = 'Goals', home.goals, away.goals)
runApp()
arenaCities <- arenaCities %>%
gather(key='GoalType', value = 'Goals', home.goals, away.goals) %>%
gather(key = 'WinType', value = 'Wins', home.win, away.win)
View(arenaCities)
View(us_cities)
runApp()
x <- c("New York", "Virginia")
state.abb[match(x,state.name)]
runApp()
dfGroupByArena$locationName <- state.abb[match(dfGroupByArena$locationName, state.name)]
colnames(dfGroupByArena)[7] <- 'country.etc'
View(dfGroupByArena)
runApp()
df <- dataStatYear[,c('name','home.win','away.win','home.goals','away.goals')]
dfGroupByArena <- aggregate(. ~ name , df, sum)
colnames(dfGroupByArena)[1] <- 'venue.name'
dfGroupByArena <- merge(dfGroupByArena, vF_teams_DT[,c('venue.name', 'venue.city', 'locationName', 'division.name')], by = 'venue.name')
colnames(dfGroupByArena)[6] <- 'name'
us_cities <- us.cities
us_cities$name <- str_sub(us_cities$name, end = -4)
dfGroupByArena$locationName <- state.abb[match(dfGroupByArena$locationName, state.name)]
View(dfGroupByArena)
df <- dataStatYear[,c('name','home.win','away.win','home.goals','away.goals')]
dfGroupByArena <- aggregate(. ~ name , df, sum)
colnames(dfGroupByArena)[1] <- 'venue.name'
dfGroupByArena <- merge(dfGroupByArena, vF_teams_DT[,c('venue.name', 'venue.city', 'locationName', 'division.name')], by = 'venue.name')
colnames(dfGroupByArena)[6] <- 'name'
us_cities <- us.cities
us_cities$name <- str_sub(us_cities$name, end = -4)
View(dfGroupByArena)
state.abb[match(dfGroupByArena$locationName, state.name)]
View(dfGroupByArena)
state.abb[match('Dallas', state.name)]
View(us_cities)
runApp()
arenaCities %>% distinct(name, .keep_all = FALSE)
arenaCities %>% distinct(name, .keep_all = TRUE)
View(arenaCities)
runApp()
runApp()
runApp()
View(vF_game_info)
View(vF_game_teams_stats)
View(vF_game_shootout_status)
View(vF_game_skater_stats)
View(vF_game_goalie_stats)
View(vF_game_plays)
View(vF_game_teams_stats)
runApp()
runApp()
View(vF_game_info)
View(vF_teams_DT)
teamIds <- vF_teams_DT[long.name %in% c(1,2,3)]$team.id
year <- 2018
upper_lim <- as.numeric(year) +1
upper_lim <- paste0(as.character(upper_lim),'000000')
lower_lim <- as.numeric(year) -1
lower_lim <- paste0( as.character(lower_lim),'999999')
df <- vF_game_teams_stats[team.id %in% teamIds & (as.numeric(game.id) > as.numeric(lower_lim) & as.numeric(game.id) < as.numeric(upper_lim))]
View(df)
teamIds
teamIds <- vF_teams_DT[long.name %in% c('New Jersey Devils', 'Boston Bruins', 'Calgary Flames' )]$team.id
teamIds
upper_lim <- as.numeric(year) +1
upper_lim <- paste0(as.character(upper_lim),'000000')
lower_lim <- as.numeric(year) -1
lower_lim <- paste0( as.character(lower_lim),'999999')
df <- vF_game_teams_stats[team.id %in% teamIds & (as.numeric(game.id) > as.numeric(lower_lim) & as.numeric(game.id) < as.numeric(upper_lim))]
View(df)
runApp()
df <- vF_game_teams_stats[team.id %in% teamIds]
View(df)
str_sub(df$game.id, end=-6)
df$game.id <- sub_str(df$game.id, edn=-7)
df$game.id <- str_sub(df$game.id, edn=-7)
df$game.id <- str_sub(df$game.id, end=-7)
View(df)
View(df)
df %>% group_by(game.id, team.id, HoA) %>% summarise(funs(sum()))
df %>% group_by(game.id, team.id, HoA) %>% summarise(funs(sum))
df %>% group_by(game.id, team.id, HoA) %>% summarise_each(funs(sum))
df <- vF_game_teams_stats[team.id %in% teamIds]
df <- vF_game_teams_stats[team.id %in% teamIds]
df$game.id <- str_sub(df$game.id, end=-7)
df <- as.data.frame(df %>% group_by(game.id, team.id, HoA) %>% summarise_each(funs(sum)))
View(df)
dfHome <- df[df$HoA == 'home']
dfHome <- df[df$HoA == 'home',]
View(dfHome)
dfTotal <- df[, -c('HoA')]
dfTotal <- subset(df, select = -c(away))
dfTotal <- subset(df, select = -c('away'))
dfTotal <- subset(df, select = -c('HoA'))
df[,!c('HoA')]
df[,!(columns(df) %in% c('HoA'))]
df[,!(colnames(df) %in% c('HoA'))]
df <- df[,c('game.id', "team.id", 'HoA', 'won')]
dfHome <- df[df$HoA == 'home',]
dfAway <- df[df$HoA == 'away',]
dfTotal <- df[,!(colnames(df) %in% c('HoA'))]
dfTotal <- aggregate(.~game.id+team.id, dfTotal, sum)
View(dfTotal)
dfTotal %>% spread(key=team.id, value=won)
ggplot(dfTotal, aes(game.id, value)) +
geom_bar(aes(fill = variable), position = "dodge", stat="identity")
Names=c("Food","Music","People") # create list of names
data=data.frame(cbind(freq),Names) # combine them into a data frame
data=data[,c(5,3,1,2,4)] # sort columns
# melt the data frame for plotting
data.m <- melt(data, id.vars='Names')
library(melt)
library(reshape2)
dfTotal <- melt(dfTotal, id.vars = 'game.id')
ggplot(data=dfTotal, aes(x=game.id, y=value, fill=variable)) +
geom_bar(stat="identity", position=position_dodge())
df <- vF_game_teams_stats[team.id %in% teamIds]
df <- vF_game_teams_stats[team.id %in% teamIds]
df$game.id <- str_sub(df$game.id, end=-7)
df <- as.data.frame(df %>% group_by(game.id, team.id, HoA) %>% summarise_each(funs(sum)))
df <- df[,c('game.id', "team.id", 'HoA', 'won')]
dfHome <- df[df$HoA == 'home',]
dfAway <- df[df$HoA == 'away',]
dfTotal <- df[,!(colnames(df) %in% c('HoA'))]
dfTotal <- aggregate(.~game.id+team.id, dfTotal, sum)
dfTotal <- melt(dfTotal, id.vars = 'game.id')
ggplot(data=dfTotal, aes(x=game.id, y=value, fill=variable)) +
geom_bar(stat="identity", position=position_dodge())
teamIds <- vF_teams_DT[long.name %in% c(input$teamPerf1, input$teamPerf2, input$teamPerf3)]$team.id
df <- vF_game_teams_stats[team.id %in% teamIds]
df <- vF_game_teams_stats[team.id %in% teamIds]
df$game.id <- str_sub(df$game.id, end=-7)
df <- as.data.frame(df %>% group_by(game.id, team.id, HoA) %>% summarise_each(funs(sum)))
df <- df[,c('game.id', "team.id", 'HoA', 'won')]
dfHome <- df[df$HoA == 'home',]
dfAway <- df[df$HoA == 'away',]
dfTotal <- df[,!(colnames(df) %in% c('HoA'))]
View(dfTotal)
dfTotal %>% spread(key = 'team.id', vvalue = 'won')
dfTotal %>% spread(key = 'team.id', value = 'won')
dfTotal %>% spread(key = 'team.id', value = 'won')
dfTotal <- aggregate(.~game.id+team.id, dfTotal, sum)
dfTotal %>% spread(key = 'team.id', value = 'won')
dfTotal <- melt(dfTotal, id.vars = 'game.id')
ggplot(data=dfTotal, aes(x=game.id, y=value, fill=variable)) +
geom_bar(stat="identity", position=position_dodge())
dfTotal
df <- vF_game_teams_stats[team.id %in% teamIds]
df <- vF_game_teams_stats[team.id %in% teamIds]
df$game.id <- str_sub(df$game.id, end=-7)
df <- as.data.frame(df %>% group_by(game.id, team.id, HoA) %>% summarise_each(funs(sum)))
df <- df[,c('game.id', "team.id", 'HoA', 'won')]
dfHome <- df[df$HoA == 'home',]
dfAway <- df[df$HoA == 'away',]
dfTotal <- df[,!(colnames(df) %in% c('HoA'))]
dfTotal <- aggregate(.~game.id+team.id, dfTotal, sum)
dfTotal <- dfTotal %>% spread(key = 'team.id', value = 'won')
dfTotal
melt(dfTotal, id.vars = 'game.id')
dfTotalMelt <- melt(dfTotal, id.vars = 'game.id')
ggplot(data=dfTotalMelt, aes(x=game.id, y=value, fill=variable)) +
geom_bar(stat="identity", position=position_dodge())
ggplot(data=dfTotalMelt, aes(x=game.id, y=value, fill=variable, size=0.25, width=0.8, alpha=0.8)) +
geom_bar(stat="identity", position=position_dodge()) + ylab('Total wins')
ggplot(data=dfTotalMelt, aes(x=game.id, y=value, size=0.25, width=0.5, alpha=0.8)) +
geom_bar(stat="identity", position=position_dodge()) + ylab('Total wins')
ggplot(data=dfTotalMelt, aes(x=game.id, y=value, fill=variable, size=0.25, width=0.1)) +
geom_bar(stat="identity", position=position_dodge()) + ylab('Total wins')
ggplot(data=dfTotalMelt, aes(x=game.id, y=value, fill=variable, size=0.25, width=0.3)) +
geom_bar(stat="identity", position=position_dodge()) + ylab('Total wins')
ggplot(data=dfTotalMelt, aes(x=game.id, y=value, fill=variable, size=0.25, width=0.4)) +
geom_bar(stat="identity", position=position_dodge()) + ylab('Total wins')
ggplot(data=dfTotalMelt, aes(x=game.id, y=value, fill=variable, size=0.25, width=0.3)) +
geom_bar(stat="identity", position=position_dodge()) + ylab('Total wins') +
scale_fill_manual("legend", values = c(teamIds[1] = "black", teamIds[2] = "orange", teamIds[3] = "blue"))
ggplot(data=dfTotalMelt, aes(x=game.id, y=value, fill=variable, size=0.25, width=0.3)) +
geom_bar(stat="identity", position=position_dodge()) + ylab('Total wins')
ggplot(data=dfTotalMelt, aes(x=game.id, y=value, fill=variable, size=0.25, width=0.3)) +
geom_bar(stat="identity", position=position_dodge()) + ylab('Total wins') +
scale_fill_manual("legend", values = c("black", "orange", "blue"))
runApp()
df <- vF_game_teams_stats[team.id %in% teamIds]
df <- vF_game_teams_stats[team.id %in% teamIds]
df$game.id <- str_sub(df$game.id, end=-7)
df <- as.data.frame(df %>% group_by(game.id, team.id, HoA) %>% summarise_each(funs(sum)))
df <- df[,c('game.id', "team.id", 'HoA', 'won')]
dfHome <- df[df$HoA == 'home',]
dfAway <- df[df$HoA == 'away',]
dfTotal <- df[,!(colnames(df) %in% c('HoA'))]
dfTotal <- aggregate(.~game.id+team.id, dfTotal, sum)
dfTotal
merge(dfTotal, dfHome, by=c('game.id','team.id'))
dfHome
merge(dfTotal, dfHome[,c('game.id','team.id')], by=c('game.id','team.id'))
merge(dfTotal, dfHome[,c('game.id','team.id','won')], by=c('game.id','team.id'))
dfTotal <- merge(dfTotal, dfHome[,c('game.id','team.id','won')], by=c('game.id','team.id'))
dfTotal %>% spread(key = 'team.id', value = c('won.x','won.y'))
dfTotal %>% spread(key = 'team.id', value = c('won.x'))
dfHome
runApp()
View(vF_game_info)
shiny::runApp()
shiny::runApp()
runApp()
test <- data.frame(person=c("A", "B", "C", "D", "E"),
value1=c(100,150,120,80,150),
value2=c(25,30,45,30,30) ,
value3=c(100,120,150,150,200))
test
melted <- melt(test, "person")
melted
df <- vF_game_teams_stats[team.id %in% c(1,2,3)]
df$game.id <- str_sub(df$game.id, end=-7)
View(df)
df <- as.data.frame(df %>% group_by(game.id, team.id, HoA) %>% summarise_each(funs(sum)))
df <- df[,c('game.id', "team.id", 'HoA', 'won')]
View(df)
melted
ggplot() + geom_bar(data =df, aes(y = won, x = team.id, fill = HoA), stat = "identity", position = 'stack') + theme_bw() + facet_grid(~game.id)
runApp()
df
ggplot() +
geom_bar(data =df, aes(y = won, x = team.id, fill = HoA), stat = "identity", position = 'stack') +
theme_bw() +
facet_grid(~game.id)
runApp()
df <- vF_game_teams_stats[team.id %in% c(1,2,3)]
View(df)
runApp()
shiny::runApp()
shiny::runApp()
shiny::runApp()
runApp()
runApp()
runApp()
runApp()
shiny::runApp()
runApp()
runApp()
shiny::runApp()
library(rsconnect)
deployApp()
rsconnect::showLogs()
runApp()
runApp()
shiny::runApp()
runApp()
runApp()
runApp()
runApp()
runApp()
View(vF_teams_DT)
runApp()
dataStatYear <- vF_game_info[vF_game_info$season == 2018]
df <- dataStatYear[,c('name','home.win','away.win','home.goals','away.goals')]
dfGroupByArena <- aggregate(. ~ name , df, sum)
colnames(dfGroupByArena)[1] <- 'venue.name'
dfGroupByArena <- merge(dfGroupByArena, vF_teams_DT[,c('venue.name', 'long.name', 'venue.city', 'locationName', 'division.name')], by = 'venue.name')
colnames(dfGroupByArena) <- c('Name', 'Home Wins', 'Away Wins', 'Home Goals', 'Away Goals', 'Home Team', 'City', 'Location', 'Division')
dfGroupByArena <- dfGroupByArena[,c('Name', 'Home Wins', 'Away Wins', 'Home Goals', 'Away Goals', 'Home Team', 'Division')]
View(dfGroupByArena)
dfGroupByArena[order(Name),]
dfGroupByArena[order(Name),]
dfGroupByArena[order('Name'),]
df <- dfGroupByArena[order('Name'),]
df
df <- dfGroupByArena[order('Name'),:]
sort(dfGroupByArena, Name)
sort(dfGroupByArena, f~ Name)
sort(dfGroupByArena, f~ -Name)
sort(dfGroupByArena, f~ -'Name')
runApp()