-
Notifications
You must be signed in to change notification settings - Fork 0
/
VideoGameSales_notebook.Rmd
568 lines (532 loc) · 41.3 KB
/
VideoGameSales_notebook.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
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
---
title: "Project part 2"
author: "Brennan Donnell"
date: "11/5/2018"
output: html_document
---
[Shinyapp.io](https://bjn82.shinyapps.io/VG_Sales/)
I've picked the [Video Games sales dataset](https://www.kaggle.com/gregorut/videogamesales).
Reason: I like video games, particularly old systems. It interests me to see how the technology has shifted. The rise and fall of developers such as Sega, the flaws and features of consoles, and more.
```{r imports, echo=FALSE,warning=FALSE,message=FALSE,error=FALSE}
library(dplyr)
library(stringr)
library(rebus)
library(data.table)
library(ggplot2)
library(lubridate)
library(shiny)
library(plotly)
library(markdown)
```
```{r load_data}
df <- tbl_df(fread('vgsales.csv',
header=T,
fill=TRUE,
sep=","))
```
First thing to do is to remove NAs for columns. While there could be many reasons for the year missing, it could likely be due to
* not being released as of when the data was published
* A game that was cancelled
Also, to look at games where there either is no info about a publisher or the publisher is unknown.
```{r clean_data}
df_filt <- df %>%
filter(Year != 'N/A') %>%
filter(Publisher != 'N/A')%>%
filter(Publisher!= 'Unknown')
df_filt$Year <- as.numeric(df_filt$Year)
df_filt <- df_filt %>%
filter(Year <= year(Sys.Date()))
rm(df)
region_sales <- 7:11
names(region_sales) <- names(df_filt[7:11])
```
Now, I want to track games by if they are part of a series. e.g.: Mario, Halo, Metal Gear, Zelda, etc.
the code for this is ugly.
```{r series_data}
seg_9 <- function(x){
ifelse(grepl('God of War',x) | grepl('God Of War', x), 'God of War',
ifelse(grepl('Tropico',x),'Tropico',
ifelse(grepl('Tony Hawk',x), 'Tony Hawk Game',
ifelse(grepl('Fable',x), 'Fable',
ifelse(grepl('TMNT',x) | grepl('Teenage Mutant', x), "TMNT",
ifelse(grepl('Def Jam', x), 'Def Jam',
ifelse(grepl('Hyperdimens', x), 'Hyperdimension Neptunia',
ifelse(grepl('PES',x) | grepl('Pro Evolution Soccer', x), 'PES',
ifelse(grepl('Ace Combat', x), "Ace Combat",
ifelse(grepl("Army Men", x), "Army Men",
ifelse(grepl('SOCOM', x), 'SOCOM',
ifelse(grepl('KillZone', x), 'Killzone',
ifelse(grepl('Army of Two', x) | grepl('Army Of Two', x), 'Army of Two',
ifelse(grepl('Duke N', x), 'Duke Nukem', ifelse(grepl('NFL Blitz', x), 'NFL Blitz',
ifelse(grepl('Miku', x) | grepl('Mirai', x), 'Hatsune Miku',
ifelse(grepl('NASCAR',x), 'NASCAR game', ifelse(grepl('DarkStalker', x), 'Darkstalkers',
ifelse(grepl('LEGO',x), 'LEGO',
ifelse(grepl('Final Fight',x), 'Final Fight',
ifelse(grepl('Sailor Moon', x), 'Sailor Moon',
ifelse(grepl('Shrek',x),'Shrek',
ifelse(grepl('Scooby',x),'Scooby-Doo',
ifelse(grepl('Lost Planet',x),'Lost Planet',
ifelse(grepl('Corpse Party',x),'Corpse Party',
ifelse(grepl('Backyard',x),'Backyard Sports',
ifelse(grepl('Leisure Suit',x),'Leisure Suit Larry',
ifelse(grepl('Dragon Warrior',x),'Dragon Warrior',
ifelse(grepl('Monster Jam',x),'Monster Jam',
ifelse(grepl('no Stafi',x),'Stafi',
ifelse(grepl('Call of Juarez',x),'Call of Juarez',
ifelse(grepl('Chibi-',x),'Chibi-Robo',
ifelse(grepl('Transformer',x),'Transformers',
ifelse(grepl('NCAA',x),'NCAA',
ifelse(grepl('Tetris',x),'Tetris game',
ifelse(grepl('Robotech',x),'Robotech',
ifelse(grepl('Pikmin',x), 'Pikmin', 'other')))))))))))))))))))))))))))))))))))))
}
seg_8 <- function(x){
ifelse(grepl('Elder Scrolls',x),'Elder Scrolls',
ifelse(grepl('Idolmaster',x) | grepl('IdolMaster',x) | grepl('Idolm@',x)|grepl('IdolM@',x),'Idolmaster',
ifelse(grepl('King of Fighters',x) | grepl('King Of Fighter',x),'KoF',
ifelse(grepl('Lord of the Rings',x) | grepl('Hobbit',x),'LotR',
ifelse(grepl('Simpsons',x),'The Simpsons',
ifelse(grepl('The Sims',x),'The Sims',
ifelse(grepl('Time Crisis',x),'Time Crisis',
ifelse(grepl('Toukiden',x),'Toukiden',
ifelse(grepl('Trauma',x),'Trauma Center',
ifelse(grepl('Turok',x),'Turok',
ifelse(grepl('Twisted Metal',x),'Twisted Metal',
ifelse(grepl('Unreal',x),'Unreal Tournament',
ifelse(grepl('Warhammer',x),'Warhammer',
ifelse(grepl('Warriors Orochi',x),'Warriors Orochi',
ifelse(grepl('Wolfenstein',x),'Wolfenstein',
ifelse(grepl('Warcraft',x),'WoW',
ifelse(grepl('Worms',x),'Worms',
ifelse(grepl('X-Men',x),'X-Men',
ifelse(grepl('Yakuza',x),'Yakuza',
ifelse(grepl('Yoshi',x),'Yoshi',
ifelse(grepl('Yu-Gi-Oh!',x),'Yu-Gi-Oh!',
ifelse(grepl('Touhou',x),'Touhou',
ifelse(grepl('Uncharted',x),'Uncharted',
ifelse(grepl('Tom Clancy',x),'Tom Clancy',seg_9(x)
))))))))))))))))))))))))
}
seg_7 <- function(x){
ifelse(grepl('Romance of the',x),"Romance of the Three Kingdoms",
ifelse(grepl('Rune Factory',x),'Rune Factory',
ifelse(grepl('Saints Row',x),'Saints Row',
ifelse(grepl('Sakura Wars',x),'Sakura Wars',
ifelse(grepl('Samurai Warriors',x),'Samurai Warriors',
ifelse(grepl('Senran Kagura',x),'Senran Kagura',
ifelse(grepl('Serious Sam',x),'Serious Sam',
ifelse(grepl('Shin Megami', x) | grepl('SMT',x)|grepl('Megami Tensei',x),'SMT',
ifelse(grepl('Silent Hill',x),'Silent Hill',
ifelse(grepl('Skylander',x),'Skylanders',
ifelse(grepl('SoulCalibur',x),'Soul Calibur',
ifelse(grepl('Spider-',x),'Spider-Man',
ifelse(grepl('SpongeBob',x),'SpongeBob',
ifelse(grepl('Spyro',x),'Spyro',
ifelse(grepl('SSX',x),'SSX',
ifelse(grepl('Star Fox',x),'Star Fox',
ifelse(grepl('Star Trek',x),'Star Trek',
ifelse(grepl('Star Ocean',x),'Star Ocean',
ifelse(grepl('Street Fighter',x),'Street Fighter',
ifelse(grepl('Suikoden',x),'Suikoden',
ifelse(grepl('Monkey Ball',x),'Monkey Ball',
ifelse(grepl('Super Robot',x),'Super Robot',
ifelse(grepl('Smash Bros',x),'Smash Bros',
ifelse(grepl('Tales of',x),'Tales of',
ifelse(grepl('Tamagotchi',x),'Tamagotchi',
ifelse(grepl('Tekken',x),'Tekken',seg_8(x)
))))))))))))))))))))))))))
}
seg_6 <- function(x){
ifelse(grepl('Just Dance',x),'Just Dance',
ifelse(grepl('Kingdom Hearts',x),'Kingdom Hearts',
ifelse(grepl('Kirby',x),'Kirby',
ifelse(grepl('Tomb Raider',x)|grepl('Lara Croft',x),'Tomb Raider',
ifelse(grepl('LittleBigPlanet',x),'LBP',
ifelse(grepl('Madden',x),'Madden',
ifelse(grepl('Sonic',x)|grepl('Knuckles',x)|grepl('Tails',x),'Sonic',
ifelse(grepl('Mass Effect',x),'Mass Effect',
ifelse(grepl('Max Payne',x),'Max Payne',
ifelse(grepl('Medal of Honor',x),'Medal of Honor',
ifelse(grepl('Mega Man',x),'Mega Man',
ifelse(grepl('Metal Gear',x),'Metal Gear',
ifelse(grepl('Metal Slug',x),'Metal Slug',
ifelse(grepl('Metroid',x),'Metroid',
ifelse(grepl('Midnight Club',x),'Midnight Club',
ifelse(grepl('MonHun',x)|grepl('Monster Hunter',x),'Monster Hunter',
ifelse(grepl('Mortal Kombat',x),'Mortal Kombat',
ifelse(grepl('Mother ',x)|grepl('EarthBound',x),'Mother',
ifelse(grepl('Naruto',x),'Naruto',
ifelse(grepl('Need for Speed',x)|grepl('Need For Speed',x),'NfS',
ifelse(grepl('Ninja Gaiden',x),'Ninja Gaiden',
ifelse(grepl('PAC-MAN',x)|grepl('Pac-Man',x),'Pac-Man',
ifelse(grepl('Persona',x) & !grepl('Personal',x),'Persona',
ifelse(grepl('Phantasy Star',x),'Phantasy Star',
ifelse(grepl('Ace Attorney',x),'Ace Attorney',
ifelse(grepl('Prince of Persia',x),'Prince of Persia',
ifelse(grepl('Layton',x),'Professor Layton',
ifelse(grepl('Quake',x),'Quake',
ifelse(grepl('Ratchet',x),'Ratchet & Clank',
ifelse(grepl('Rayman',x),'Rayman',
ifelse(grepl('Red Dead',x),'Red Dead Redemption',
ifelse(grepl('Red Faction',x),'Red Faction',
ifelse(grepl('Resident Evil',x),'RE',seg_7(x))
))))))))))))))))))))))))))))))))
}
seg_5 <- function(x){
ifelse(grepl('Ape Escape',x),'Ape Escape',
ifelse(grepl('Far Cry',x),'Far Cry',
ifelse(grepl('Farming Simulator',x),'Farming Simulator',
ifelse(grepl('Fatal Frame',x),'Fatal Frame',
ifelse(grepl('Fire Emblem',x),'Fire Emblem',
ifelse(grepl('Forza',x),'Forza',
ifelse(grepl('Frogger',x),'Frogger',
ifelse(grepl('Gears of War',x),'Gears of War',
ifelse(grepl('God Eater',x),'God Eater',
ifelse(grepl('Golden Sun',x),'Golden Sun',
ifelse(grepl('Rock Band',x),'Rock Band',
ifelse(grepl('Guild Wars',x),'Guild Wars',
ifelse(grepl('Guilty Gear',x),'Guilty Gear',
ifelse(grepl('Guitar Hero',x),'Guitar Hero',
ifelse(grepl('Gundam',x),'Gundam',
ifelse(grepl('Half-Life',x),'Half-Life',
ifelse(grepl('Harvest Moon',x),'Harvest Moon',
ifelse(grepl('Hitman',x) & !grepl('Reborn!',x),'Hitman',
ifelse(grepl('Indiana Jones',x),'Indiana Jones',
ifelse(grepl('Just Cause',x),'Just Cause',seg_6(x))
)))))))))))))))))))
}
seg_4 <- function(x){
ifelse(grepl('CSI',x),'CSI',
ifelse(grepl('Custom Robo',x),'Custom Robo',
ifelse(grepl('Dance Dance Revolution',x),'DDR',
ifelse(grepl('Dark Souls', x), 'Dark Souls',
ifelse(grepl('Darksiders',x), 'Darksiders',
ifelse(grepl('Dead Island',x),'Dead Island',
ifelse(grepl('Dead or Alive',x),'DoA',
ifelse(grepl('Dead Rising',x),'Dead Rising',
ifelse(grepl('Dead Space',x),'Dead Space',
ifelse(grepl('Dead to Rights',x),'Dead to Rights',
ifelse(grepl('Deus Ex',x),'Deus Ex',
ifelse(grepl('Devil May Cry',x),'DMC',
ifelse(grepl('Diablo',x),'Diablo',
ifelse(grepl('Digimon',x),'Digimon',
ifelse(grepl('Disgaea',x),'Disgaea',
ifelse(grepl('Doom',x) & !grepl('of Doom',x),'Doom',
ifelse(grepl('Dragon Age',x),'Dragon Age',
ifelse(grepl('Dragon Ball',x),'Dragon Ball',
ifelse(grepl('Dragon Quest',x),'Dragon Quest',
ifelse(grepl('Dynasty Warriors',x),'Dynasty Warriors',
ifelse(grepl('Etrian',x),'Etrian Odyssey',
ifelse(grepl('F-Zero',x),'F-Zero',
ifelse(grepl('F.E.A.R',x),'FEAR',
ifelse(grepl('Fallout',x),'Fallout',
ifelse(grepl("Assassins's",x),"Assassin's Creed",
ifelse(grepl('Armored Core',x),'Armored Core',
ifelse(grepl('Atelier',x),'Atelier',
ifelse(grepl('Batman',x),'Batman',
ifelse(grepl("Assassin's",x),"Assassin's Creed", seg_5(x)
)))))))))))))))))))))))))))))
}
seg_3 <- function(x){
ifelse(grepl('BioShock',x),'BioShock',
ifelse(grepl('BlazBlue',x) | grepl('Blazblue',x),'BlazBlue',
ifelse(grepl('Bleach',x),'Bleach',
ifelse(grepl('Bloody Roar',x),'Bloody Roar',
ifelse(grepl('Bomberman',x),'Bomberman',
ifelse(grepl('Borderlands',x),'Borderlands',
ifelse(grepl('Bratz',x),'Bratz',
ifelse(grepl('Breath of Fire',x),'Breath of Fire',
ifelse(grepl('Broken Sword',x),'Broken Sword',
ifelse(grepl('Brothers in Arms',x)|grepl('Brothers In Arms',x),'Brothers in Arms',
ifelse(grepl('Burnout',x),'Burnout',
ifelse(grepl('Buzz!',x),'Buzz!',
ifelse(grepl('Cabela',x),'Cabela',
ifelse(grepl('Carmen Sandiego',x),'Carmen Sandiego',
ifelse(grepl('Castlevania',x),'Castlevania',
ifelse(grepl('Donkey Kong',x)|grepl('Diddy Kong',x), 'Donkey Kong',
ifelse(grepl('Clock Tower',x),'Clock Tower',
ifelse(grepl('Command & Conquer',x),'Command & Conquer',
ifelse(grepl('Cooking Mama',x),'Cooking Mama',
ifelse(grepl('Crash',x),'Crash Bandicoot',
ifelse(grepl('Crazy Taxi',x), 'Crazy Taxi',
ifelse(grepl('Crysis',x),'Crysis', seg_4(x))
)))))))))))))))))))))
}
seg_2 <- function(x){
ifelse(grepl('Animal Crossing',x), 'Animal Crossing',
ifelse(grepl('Gran Turismo',x), 'Gran Turismo',
ifelse(grepl('Star Wars',x), 'Star Wars',
ifelse(grepl('FIFA',x), 'FIFA',
ifelse(grepl('Battlefield',x),'Battlefield',
ifelse(grepl('.hack',x, fixed = TRUE), '.hack',
ifelse(grepl('Super Robot Wars',x),'Super Robot Wars',
ifelse(grepl('Battle of Giants',x),'Battle of Giants',
ifelse(grepl('Battle Spirits',x),'Battle Spirits',
ifelse(grepl('Battlestations',x),'Battlestations',
ifelse(grepl('Bayonetta',x),'Bayonetta',
ifelse(grepl('BeatMania',x),'BeatMania',
ifelse(grepl('Katamari',x),'Katamari',
ifelse(grepl('Ben 10',x),'Ben 10',
ifelse(grepl('Beyblade',x)|grepl('BeyBlade',x),'Beyblade',
ifelse(grepl('Banjo',x) & !grepl('Sonic',x) & !grepl('Geass',x),'Banjo Kazooie',seg_3(x))
)))))))))))))))
}
seg_1 <- function(x){
ifelse(grepl('Mario Kart', x), 'Mario Kart',
ifelse(grepl('Mario Party', x), 'Mario Party',
ifelse(grepl('Mario Tennis',x),'Mario Tennis',
ifelse(grepl('Mario & Sonic',x),'Mario & Sonic',
ifelse(grepl('Zelda',x), 'Zelda',
ifelse(grepl('Mario', x) | grepl('Luigi', x) | grepl('Captain Toad',x) | grepl('Wario',x) & !grepl('Marionette',x), 'Mario',
ifelse(grepl('Pokemon', x) | grepl('Pokémon',x), 'Pokemon',
ifelse(grepl('Halo', x), 'Halo',
ifelse(grepl('Final Fantasy',x), 'Final Fantasy',
ifelse(grepl('Call of Duty',x), 'Call of Duty',
ifelse(grepl('Grand Theft Auto', x),'GTA',seg_2(x))
))))))))))
}
series_seg <- function(x){
seg_1(x)
}
df_filt$Series <-
sapply(df_filt$Name, series_seg) #that's how sapply works. look up notes.
```
```{r top_ten_platform}
df_plat <- df_filt %>%
group_by(Platform) %>%
summarise(n=n())
top_sales <- function(vg_sys){
df_vg <- df_filt %>%
filter(Platform == vg_sys) %>%
arrange(Rank)
return(head(df_vg, n = 10))
}
```
The purpose of this part is to show how many games in the chart corresponded to a given genre for all platforms. It was my dad's idea, and as the chunk is named, a last minute idea.
```{r last_Minute}
df_genre <- df_filt %>%
filter(Genre == 'Sports') %>%
group_by(Platform) %>%
summarise(n=n())
ggplot(data = df_genre, aes(x=Platform, y=n, fill = Platform)) + geom_col() + theme_classic()
```
```{r shiny_app}
ui_full <- navbarPage(
title = "Video Games",
tabPanel(title = "Readme",
includeMarkdown("readme.md")
),
tabPanel(title = "Scatterplot",
sidebarLayout(
sidebarPanel(
radioButtons(
inputId = "region_ui",
label = "Select Region",
choices = names(region_sales),
selected = names(region_sales[1]),
inline = TRUE),
selectInput(
inputId = "series_ui",
label = "Select Series",
choices = unique(df_filt$Series),
selected = unique(df_filt$Series)[2])
),
mainPanel(
h2(str_c("Scatterplot of Global Sales by Platform",
" for a given series")),
plotlyOutput(outputId = "scatter")
)
)
),
tabPanel(title = "Publisher Sales Chart",
sidebarLayout(
sidebarPanel(
selectInput(
inputId = "publisher_ui",
label = "Select Publisher",
choices = unique(df_filt$Publisher),
selected = unique(df_filt$Publisher)[1])
),
mainPanel(
h2("Barchart of frequency of genre for a given publisher"),
plotOutput(outputId = "bar")
)
)
),
tabPanel(title = "Console Sales Table",
sidebarLayout(
sidebarPanel(
sliderInput(
inputId = "range",
label = "Year range",
min = min(df_filt$Year),
max = max(df_filt$Year),
value = c(1995, 2005),
sep = ""
)
),
mainPanel(
h2("Console game sales throughout the years"),
splitLayout(
tableOutput(outputId = "table"),
plotOutput(outputId = "table_bar"))))
),
tabPanel(title = 'Sales by Genre',
sidebarLayout(
sidebarPanel(
selectInput(
inputId = 'gen',
label = "Select Genre",
choices = unique(df_filt$Genre),
selected = unique(df_filt$Genre)[1]
)
),
mainPanel(
h2("Plot of genre sales by platform"),
plotOutput(
outputId = 'gen_bar'
)
)
)
),
tabPanel(title = "Facts",
sidebarLayout(
sidebarPanel(
selectInput(
inputId = "sys",
label = "Select System",
choices = unique(df_filt$Platform))
),
mainPanel(
tabsetPanel(
tabPanel(title = "Facts & Info",
splitLayout(
imageOutput(outputId = "img"),
htmlOutput(outputId = "txt")
)
),
tabPanel(title = "Table",
tableOutput(outputId = "tbl")
)
)
)
)
)
)
server_full <- function(input, output){
filtered_data_1 <- reactive({
filter(
df_filt,
Series == input$series_ui)})
filtered_data_2 <- reactive({
as.data.frame(table(filter(
df_filt,
Publisher == input$publisher_ui)$Genre))})
filtered_data_3 <- reactive({
filter(
df_filt,
Year >= min(input$range) & Year <= max(input$range))})
filtered_data_4 <- reactive({top_sales(input$sys)})
filtered_data_5 <- reactive({
df_out <- df_filt %>%
filter(Genre == input$gen) %>%
group_by(Platform) %>%
summarise(n=n())
df_out
})
filtered_text <- reactive(input$sys)
output$scatter <- renderPlotly({
ggplotly(
ggplot(
filtered_data_1(),
aes_string(
x = "Platform",
y = input$region_ui)) +
geom_point(aes(colour = Genre, text=Name)) +
theme_classic() +
theme(axis.text.x = element_text(angle = 60, hjust = 1)))}
)
output$bar <- renderPlot({
ggplot(
data = filtered_data_2(),
aes(
x = Var1,
y = Freq,
fill = Var1)) +
geom_col() +
labs(
title = names(input$publisher_ui),
x = "Genre",
y = "Frequency") +
scale_fill_hue(h = c(0,360)) +
theme_classic() +
theme(axis.text.x = element_text(angle = 60, hjust = 1))}
)
output$gen_bar <- renderPlot({
ggplot(
data = filtered_data_5(),
aes(
x = Platform,
y = n,
fill = Platform,
)
) +
geom_col() +
labs(x = "System", y = "Games") +
scale_fill_hue(h = c(0,360)) +
theme_classic() +
theme(axis.text.x = element_text(angle = 60, hjust = 1))
})
output$table <- renderTable(
{
tb <- filtered_data_3() %>%
group_by(Platform) %>%
summarise(NA_Sales = n()) %>%
arrange(desc(NA_Sales))
tb
},
striped = TRUE,
hover = TRUE
)
output$table_bar <- renderPlot(
{
ggplot(
data = filtered_data_3(),
aes(
x = Platform,
y = NA_Sales,
fill = Platform)
) +
geom_col() +
labs(x = "System", y = "Sales") +
scale_fill_hue(h = c(0,360)) +
theme_classic() +
theme(axis.text.x = element_text(angle = 60, hjust = 1))
}
)
output$img <- renderImage({
filename <- normalizePath(file.path('./www',
str_c(filtered_text(),'.jpg')))
# Return a list containining the filename
list(src = filename)
},deleteFile = FALSE )
output$txt <- renderText(
includeMarkdown(
str_c('Systems/',filtered_text(),'.md')))
output$tbl <- renderTable(
{filtered_data_4()},
striped = TRUE,
hover = TRUE
)
}
shinyApp(ui = ui_full, server = server_full)
```
## Insights from the project?
1. Games that came bundled with systems or accessories were generally the top-selling games for that platform
+ e.g.: *Wii Sports* & *Kinect Adventures*.
2. Not all systems had a top ten. And some systems that were included in the data were never released in North America
+ e.g.: the WonderSwan, TG16.
3. Certain publishers tended to put out more of certain types of games, though there is a logical explanation to it.
+ Electronic Arts puts out a lot of sports games, although they hold the licenses to many yearly sports games such as *Madden*.
+ SquareSoft (Now Square Enix) and Atlus put out primarily JRPGs
4. *Minecraft* for the PS Vita (PSV) was the top-selling PS Vita game, selling more units in Japan and Europe than in North America.