https://www.kaggle.com/datasets/deepcontractor/top-video-games-19952021-metacritic

In [2]:
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.2     ✔ readr     2.1.4
✔ forcats   1.0.0     ✔ stringr   1.5.0
✔ ggplot2   3.4.3     ✔ tibble    3.2.1
✔ lubridate 1.9.2     ✔ tidyr     1.3.0
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
In [3]:
data <- read_csv("/Users/romanguchenko/Statmod/Введение в обработку данных/all_games.csv")
Rows: 18800 Columns: 6
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (5): name, platform, release_date, summary, user_review
dbl (1): meta_score

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
In [8]:
data[1:3,]
A tibble: 3 × 6
nameplatformrelease_datesummarymeta_scoreuser_review
<chr><chr><chr><chr><dbl><chr>
The Legend of Zelda: Ocarina of TimeNintendo 64 November 23, 1998 As a young boy, Link is tricked by Ganondorf, the King of the Gerudo Thieves. The evil human uses Link to gain access to the Sacred Realm, where he places his tainted hands on Triforce and transforms the beautiful Hyrulean landscape into a barren wasteland. Link is determined to fix the problems he helped to create, so with the help of Rauru he travels through time gathering the powers of the Seven Sages. 999.1
Tony Hawk's Pro Skater 2 PlayStation September 20, 2000As most major publishers' development efforts shift to any number of next-generation platforms, Tony Hawk 2 will likely stand as one of the last truly fantastic games to be released on the PlayStation. 987.4
Grand Theft Auto IV PlayStation 3April 29, 2008 [Metacritic's 2008 PS3 Game of the Year; Also known as "GTA IV"] What does the American Dream mean today? For Niko Belic, fresh off the boat from Europe. It's the hope he can escape his past. For his cousin, Roman, it is the vision that together they can find fortune in Liberty City, gateway to the land of opportunity. As they slip into debt and are dragged into a criminal underworld by a series of shysters, thieves and sociopaths, they discover that the reality is very different from the dream in a city that worships money and status, and is heaven for those who have them an a living nightmare for those who don't. [Rockstar Games]987.7
In [19]:
data |> 
    mutate(user_review = as.double(user_review)) |>
    slice(1:3)
Warning message:
“There was 1 warning in `mutate()`.
ℹ In argument: `user_review = as.double(user_review)`.
Caused by warning:
! в результате преобразования созданы NA”
A tibble: 3 × 6
nameplatformrelease_datesummarymeta_scoreuser_review
<chr><chr><chr><chr><dbl><dbl>
The Legend of Zelda: Ocarina of TimeNintendo 64 November 23, 1998 As a young boy, Link is tricked by Ganondorf, the King of the Gerudo Thieves. The evil human uses Link to gain access to the Sacred Realm, where he places his tainted hands on Triforce and transforms the beautiful Hyrulean landscape into a barren wasteland. Link is determined to fix the problems he helped to create, so with the help of Rauru he travels through time gathering the powers of the Seven Sages. 999.1
Tony Hawk's Pro Skater 2 PlayStation September 20, 2000As most major publishers' development efforts shift to any number of next-generation platforms, Tony Hawk 2 will likely stand as one of the last truly fantastic games to be released on the PlayStation. 987.4
Grand Theft Auto IV PlayStation 3April 29, 2008 [Metacritic's 2008 PS3 Game of the Year; Also known as "GTA IV"] What does the American Dream mean today? For Niko Belic, fresh off the boat from Europe. It's the hope he can escape his past. For his cousin, Roman, it is the vision that together they can find fortune in Liberty City, gateway to the land of opportunity. As they slip into debt and are dragged into a criminal underworld by a series of shysters, thieves and sociopaths, they discover that the reality is very different from the dream in a city that worships money and status, and is heaven for those who have them an a living nightmare for those who don't. [Rockstar Games]987.7
In [18]:
data |>
    filter(is.na(as.numeric(user_review))) |>
    slice(1:3)
Warning message:
“There was 1 warning in `filter()`.
ℹ In argument: `is.na(as.numeric(user_review))`.
Caused by warning:
! в результате преобразования созданы NA”
A spec_tbl_df: 3 × 6
nameplatformrelease_datesummarymeta_scoreuser_review
<chr><chr><chr><chr><dbl><chr>
Synth Riders PlayStation 4August 10, 2021 Synth Riders is your freestyle dancing VR rhythm alternative. Lose yourself in the incredible music, ride the rails, meet friends in the multiplayer, and become a part of the VR rhythm revolution! 89tbd
Tiger Woods PGA Tour 2005 GameCube September 20, 2004Challenge professional golfer Tiger Woods to challenging matches in Tiger Woods PGA Tour 2005. This time, you can modify course dynamics and add longer trees, tighter fairways, undulations to greens, deeper bunkers, and more. The game's EA Sports Game Face features nonproportional bone scaling and texture blending to provide more realistic looks. After creating your own golfer and making a name for yourself, unlock the chance to tee off against some of golf's greatest legends, including Arnold Palmer, Jack Nicklaus, and Ben Hogan.88tbd
NASCAR 2005: Chase for the CupXbox August 31, 2004 Do you have what it takes to be a top NASCAR driver? In NASCAR 2005: Chase for the Cup, you can become a superstar owner or driver and decide where, how, and what to drive. During races you can even rattle rivals with the all-new Intimidator button. Push them too far and you might find yourself in a postrace confrontation. Develop essential racing skills, increase fan support, and compete in four racing series to become the driver that top NASCAR teams are looking for. 86tbd
In [28]:
data |> 
    select(!summary) |>
    mutate(user_review = 10 * as.double(user_review)) |>
    slice_sample(n = 10)
Warning message:
“There was 1 warning in `mutate()`.
ℹ In argument: `user_review = 10 * as.double(user_review)`.
Caused by warning:
! в результате преобразования созданы NA”
A tibble: 10 × 5
nameplatformrelease_datemeta_scoreuser_review
<chr><chr><chr><dbl><dbl>
Crysis PC November 13, 2007 9181
Borderlands 2 PlayStation VitaMay 6, 2014 6477
Shin Megami Tensei: Nocturne PlayStation 2 October 12, 2004 8262
Captain America: Super Soldier Xbox 360 July 19, 2011 6066
A Plague Tale: Innocence Xbox One May 14, 2019 8385
Amazing Island GameCube August 25, 2004 5970
Minecraft: PlayStation 4 EditionPlayStation 4 September 3, 2014 8968
Pro Evolution Soccer 2017 Xbox One September 13, 20168759
Ultimate Block Party PSP December 13, 2005 76NA
Ready 2 Rumble Boxing: Round 2 Dreamcast October 23, 2000 7074
In [33]:
library(lubridate)
In [36]:
data$release_date[1:10]
  1. 'November 23, 1998'
  2. 'September 20, 2000'
  3. 'April 29, 2008'
  4. 'September 8, 1999'
  5. 'April 29, 2008'
  6. 'November 12, 2007'
  7. 'May 23, 2010'
  8. 'October 26, 2018'
  9. 'November 18, 2014'
  10. 'September 17, 2013'
In [35]:
parse_date_time(data$release_date[1:10], orders = c("ymd", "dmy", "mdy"))
 [1] "1998-11-23 UTC" "2000-09-20 UTC" "2008-04-29 UTC" "1999-09-08 UTC"
 [5] "2008-04-29 UTC" "2007-11-12 UTC" "2010-05-23 UTC" "2018-10-26 UTC"
 [9] "2014-11-18 UTC" "2013-09-17 UTC"
In [39]:
data |> 
    select(!summary) |>
    mutate(
        release_date = parse_date_time(release_date, orders = c("ymd", "dmy", "mdy")),
        user_review = 10 * as.double(user_review)
    ) |>
    slice_sample(n = 10)
Warning message:
“There was 1 warning in `mutate()`.
ℹ In argument: `user_review = 10 * as.double(user_review)`.
Caused by warning:
! в результате преобразования созданы NA”
A tibble: 10 × 5
nameplatformrelease_datemeta_scoreuser_review
<chr><chr><dttm><dbl><dbl>
Mass Effect 3 Xbox 360 2012-03-069360
Seven: The Days Long Gone PC 2017-12-016874
Zombie Driver: Immortal Edition Switch 2019-07-2560NA
Greak: Memories of Azur Xbox Series X 2021-08-1762NA
Rise of the Argonauts PC 2008-12-165974
The Legend of Heroes: Trails of Cold Steel IVPlayStation 4 2020-10-278187
Harry Potter and the Order of the Phoenix Xbox 360 2007-06-256848
Street Fighter EX3 PlayStation 2 2000-10-246479
Shadowrun Xbox 360 2007-05-296675
FIFA Soccer 13 PlayStation Vita2012-09-255741
In [40]:
data <- data |> 
    select(!summary) |>
    mutate(
        release_date = parse_date_time(release_date, orders = c("ymd", "dmy", "mdy")),
        user_review = 10 * as.double(user_review)
    )
Warning message:
“There was 1 warning in `mutate()`.
ℹ In argument: `user_review = 10 * as.double(user_review)`.
Caused by warning:
! в результате преобразования созданы NA”
In [43]:
data[1:5,]
A tibble: 5 × 5
nameplatformrelease_datemeta_scoreuser_review
<chr><chr><dttm><dbl><dbl>
The Legend of Zelda: Ocarina of TimeNintendo 64 1998-11-239991
Tony Hawk's Pro Skater 2 PlayStation 2000-09-209874
Grand Theft Auto IV PlayStation 32008-04-299877
SoulCalibur Dreamcast 1999-09-089884
Grand Theft Auto IV Xbox 360 2008-04-299879
In [46]:
dim(data)
  1. 18800
  2. 5
In [50]:
n_distinct(data$name)
12254
In [61]:
data |>
    count(game_name = name, name = 'num_platforms') |>
    slice(1:10)
A tibble: 10 × 2
game_namenum_platforms
<chr><int>
#DRIVE 1
#IDARB 1
#KILLALLZOMBIES 1
'Splosion Man 1
.detuned 1
.hack//G.U. Last Recode 2
.hack//G.U. vol. 1//Rebirth 1
.hack//G.U. vol. 2//Reminisce 1
.hack//G.U. vol. 3//Redemption1
.hack//Infection Part 1 1
In [62]:
data |>
    count(game_name = name, name = 'num_platforms') |>
    count(num_platforms, name = 'num_games')
A tibble: 9 × 2
num_platformsnum_games
<int><int>
18421
21949
31302
4 419
5 102
6 43
7 15
8 1
9 2
In [66]:
data |>
    group_by(name) |>
    filter(n() >= 8) |>
    arrange(name, release_date)
A grouped_df: 26 × 5
nameplatformrelease_datemeta_scoreuser_review
<chr><chr><dttm><dbl><dbl>
Cars PC 2006-06-067377
Cars PlayStation 2 2006-06-067187
Cars GameCube 2006-06-067172
Cars Xbox 2006-06-067080
Cars PSP 2006-06-067069
Cars PlayStation 2 2006-06-065428
Cars Xbox 360 2006-06-065050
Cars Xbox 360 2006-10-236572
Cars Wii 2006-11-166570
Madden NFL 06PlayStation 2 2005-08-088880
Madden NFL 06Xbox 2005-08-088668
Madden NFL 06GameCube 2005-08-088680
Madden NFL 06Game Boy Advance2005-08-0871NA
Madden NFL 06DS 2005-08-086663
Madden NFL 06PC 2005-08-177868
Madden NFL 06PSP 2005-09-207579
Madden NFL 06Xbox 360 2005-11-167450
Madden NFL 07PlayStation 2 2006-08-228482
Madden NFL 07Xbox 2006-08-228374
Madden NFL 07GameCube 2006-08-228278
Madden NFL 07Xbox 360 2006-08-228060
Madden NFL 07PC 2006-08-228073
Madden NFL 07PSP 2006-08-227866
Madden NFL 07DS 2006-08-227065
Madden NFL 07Wii 2006-11-148181
Madden NFL 07PlayStation 3 2006-11-147647
In [71]:
data |>
    group_by(name) |>
    summarize(distinct_platforms = n_distinct(platform)) |>
    count(distinct_platforms, name = 'num_games')
A tibble: 9 × 2
distinct_platformsnum_games
<int><int>
18451
21958
31278
4 415
5 99
6 40
7 11
8 1
9 1
In [76]:
data |>
    group_by(name, platform) |>
    summarise(
        release_date = min(release_date),
        meta_score = mean(meta_score, na.rm = TRUE),
        user_review = mean(user_review, na.rm = TRUE),
        .groups = 'drop'
    ) |>
    filter(name == 'Cars')
A tibble: 7 × 5
nameplatformrelease_datemeta_scoreuser_review
<chr><chr><dttm><dbl><dbl>
CarsGameCube 2006-06-0671.072.0
CarsPC 2006-06-0673.077.0
CarsPSP 2006-06-0670.069.0
CarsPlayStation 22006-06-0662.557.5
CarsWii 2006-11-1665.070.0
CarsXbox 2006-06-0670.080.0
CarsXbox 360 2006-06-0657.561.0
In [77]:
data <- data |>
    group_by(name, platform) |>
    summarise(
        release_date = min(release_date),
        meta_score = mean(meta_score, na.rm = TRUE),
        user_review = mean(user_review, na.rm = TRUE),
        .groups = 'drop'
    )
In [79]:
unique(data$platform)
  1. 'Switch'
  2. 'Xbox One'
  3. 'Xbox'
  4. 'Xbox 360'
  5. 'PC'
  6. 'PlayStation 4'
  7. 'PlayStation 2'
  8. 'Wii'
  9. 'DS'
  10. 'PlayStation 3'
  11. 'Nintendo 64'
  12. 'PlayStation'
  13. 'PSP'
  14. 'GameCube'
  15. 'Dreamcast'
  16. 'Game Boy Advance'
  17. '3DS'
  18. 'Wii U'
  19. 'PlayStation 5'
  20. 'PlayStation Vita'
  21. 'Xbox Series X'
  22. 'Stadia'
In [81]:
data |>
    count(platform, sort = TRUE)
A tibble: 22 × 2
platformn
<chr><int>
PC 4812
PlayStation 4 2046
Xbox 360 1626
PlayStation 2 1406
Switch 1398
PlayStation 3 1252
Xbox One 1175
Xbox 788
DS 716
Wii 651
PSP 511
GameCube 446
Game Boy Advance 437
3DS 396
PlayStation Vita 257
PlayStation 187
Wii U 184
Dreamcast 125
PlayStation 5 124
Xbox Series X 77
Nintendo 64 71
Stadia 5
In [155]:
options(repr.plot.width = 20, repr.plot.height = 20)
In [156]:
ggplot(data, aes(x = user_review, y = meta_score)) +
    geom_point() + 
    xlim(0, 100) + 
    ylim(0, 100) +
    facet_wrap(~platform) + 
    theme(text = element_text(size = 30))
Warning message:
“Removed 1353 rows containing missing values (`geom_point()`).”
In [102]:
data |> 
    group_by(platform) |>
    summarise(cor = cor(meta_score, user_review, use = "complete.obs"))
A tibble: 22 × 2
platformcor
<chr><dbl>
3DS 0.6729838
DS 0.5895889
Dreamcast 0.4815993
Game Boy Advance 0.6680498
GameCube 0.6414480
Nintendo 64 0.7617740
PC 0.5115467
PSP 0.5355419
PlayStation 0.7456445
PlayStation 2 0.6085060
PlayStation 3 0.5889878
PlayStation 4 0.4456872
PlayStation 5 0.4199144
PlayStation Vita 0.6814964
Stadia -0.1337731
Switch 0.6293755
Wii 0.6296466
Wii U 0.7688050
Xbox 0.6248850
Xbox 360 0.6127384
Xbox One 0.3583382
Xbox Series X 0.3580699
In [159]:
data |> 
    group_by(platform) |>
    summarise(cor = cor(meta_score, user_review, use = "complete.obs")) |>
    filter(grepl('PlayStation', platform))
A tibble: 6 × 2
platformcor
<chr><dbl>
PlayStation 0.7456445
PlayStation 2 0.6085060
PlayStation 3 0.5889878
PlayStation 4 0.4456872
PlayStation 5 0.4199144
PlayStation Vita0.6814964
In [106]:
data |>
    filter(platform == 'PC') |>
    mutate(release_year = year(release_date)) |>
    slice(1:10)
A tibble: 10 × 6
nameplatformrelease_datemeta_scoreuser_reviewrelease_year
<chr><chr><dttm><dbl><dbl><dbl>
.hack//G.U. Last Recode PC2017-11-0369812017
007: NightFire PC2002-11-2859612002
007: Quantum of Solace PC2008-11-0470632008
0RBITALIS PC2015-05-2873732015
10 Second Ninja PC2014-03-0572712014
11-11: Memories Retold PC2018-11-0873672018
112 Operator PC2020-04-2373742020
1503 A.D. - The New WorldPC2003-03-2374762003
1701 A.D. PC2006-11-0679772006
1954: Alcatraz PC2014-03-1158632014
In [157]:
ggplot(
    data |>
        filter(platform == 'PC') |>
        mutate(release_year = year(release_date)), 
    aes(x = user_review, y = meta_score)
) +
    geom_point() + 
    xlim(0, 100) + 
    ylim(0, 100) +
    facet_wrap(~release_year) + 
    theme(text = element_text(size = 30))
Warning message:
“Removed 200 rows containing missing values (`geom_point()`).”
In [111]:
data |>
    filter(platform == 'PC') |>
    mutate(release_year = year(release_date)) |>
    filter(release_year >= 2000) |>
    group_by(release_year) |>
    summarise(cor = cor(meta_score, user_review, use = "complete.obs"))
A tibble: 22 × 2
release_yearcor
<dbl><dbl>
20000.3987361
20010.6546850
20020.5269442
20030.5938655
20040.4686154
20050.5750785
20060.5839964
20070.7127208
20080.6538982
20090.6772034
20100.5755253
20110.6349635
20120.6708502
20130.6047175
20140.5605304
20150.5237161
20160.4260962
20170.4271391
20180.4634149
20190.4222958
20200.4150902
20210.2937798
In [114]:
library(confintr)
In [138]:
cors_with_conf_intervals <- data |>
    filter(platform == 'PC') |>
    mutate(release_year = year(release_date)) |>
    filter(release_year >= 2000) |>
    group_by(release_year) |>
    summarise(
        cor = cor(meta_score, user_review, use = "complete.obs"),
        conf_lower = ci_cor(meta_score, user_review)$interval[1],
        conf_upper = ci_cor(meta_score, user_review)$interval[2]
    )
In [139]:
cors_with_conf_intervals
A tibble: 22 × 4
release_yearcorconf_lowerconf_upper
<dbl><dbl><dbl><dbl>
20000.39873610.23182160.5428424
20010.65468500.55081740.7385832
20020.52694420.40652270.6293698
20030.59386550.48986200.6812026
20040.46861540.33759170.5818251
20050.57507850.46144970.6701439
20060.58399640.47861510.6727917
20070.71272080.62718700.7812686
20080.65389820.55400410.7352301
20090.67720340.59011550.7487119
20100.57552530.45874090.6727644
20110.63496350.54128950.7130694
20120.67085020.58830020.7395623
20130.60471750.52342820.6750983
20140.56053040.47136200.6383550
20150.52371610.43635360.6012964
20160.42609620.33005490.5134062
20170.42713910.32567850.5188741
20180.46341490.36176370.5541765
20190.42229580.31627590.5178971
20200.41509020.31423520.5066802
20210.29377980.15803560.4186260
In [142]:
options(repr.plot.width = 20, repr.plot.height = 10)
In [149]:
ggplot(cors_with_conf_intervals) +
    geom_line(aes(x = release_year, y = cor)) + 
    geom_line(aes(x = release_year, y = conf_lower), color = 'Red') + 
    geom_line(aes(x = release_year, y = conf_upper), color = 'Red') + 
    theme(text = element_text(size = 30))
In [151]:
library(ggridges)
In [153]:
ggplot(
    data |> 
        mutate(diff = meta_score - user_review), 
    aes(x = diff, y = platform, fill = platform, color = platform)
) +
    geom_density_ridges(alpha = 0.5, show.legend = FALSE)
Picking joint bandwidth of 2.55

Warning message:
“Removed 1353 rows containing non-finite values (`stat_density_ridges()`).”
In [ ]: