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
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.
data[1:3,]
| name | platform | release_date | summary | meta_score | user_review |
|---|---|---|---|---|---|
| <chr> | <chr> | <chr> | <chr> | <dbl> | <chr> |
| The Legend of Zelda: Ocarina of Time | Nintendo 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. | 99 | 9.1 |
| Tony Hawk's Pro Skater 2 | PlayStation | September 20, 2000 | As 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. | 98 | 7.4 |
| Grand Theft Auto IV | PlayStation 3 | April 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] | 98 | 7.7 |
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”
| name | platform | release_date | summary | meta_score | user_review |
|---|---|---|---|---|---|
| <chr> | <chr> | <chr> | <chr> | <dbl> | <dbl> |
| The Legend of Zelda: Ocarina of Time | Nintendo 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. | 99 | 9.1 |
| Tony Hawk's Pro Skater 2 | PlayStation | September 20, 2000 | As 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. | 98 | 7.4 |
| Grand Theft Auto IV | PlayStation 3 | April 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] | 98 | 7.7 |
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”
| name | platform | release_date | summary | meta_score | user_review |
|---|---|---|---|---|---|
| <chr> | <chr> | <chr> | <chr> | <dbl> | <chr> |
| Synth Riders | PlayStation 4 | August 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! | 89 | tbd |
| Tiger Woods PGA Tour 2005 | GameCube | September 20, 2004 | Challenge 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. | 88 | tbd |
| NASCAR 2005: Chase for the Cup | Xbox | 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. | 86 | tbd |
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”
| name | platform | release_date | meta_score | user_review |
|---|---|---|---|---|
| <chr> | <chr> | <chr> | <dbl> | <dbl> |
| Crysis | PC | November 13, 2007 | 91 | 81 |
| Borderlands 2 | PlayStation Vita | May 6, 2014 | 64 | 77 |
| Shin Megami Tensei: Nocturne | PlayStation 2 | October 12, 2004 | 82 | 62 |
| Captain America: Super Soldier | Xbox 360 | July 19, 2011 | 60 | 66 |
| A Plague Tale: Innocence | Xbox One | May 14, 2019 | 83 | 85 |
| Amazing Island | GameCube | August 25, 2004 | 59 | 70 |
| Minecraft: PlayStation 4 Edition | PlayStation 4 | September 3, 2014 | 89 | 68 |
| Pro Evolution Soccer 2017 | Xbox One | September 13, 2016 | 87 | 59 |
| Ultimate Block Party | PSP | December 13, 2005 | 76 | NA |
| Ready 2 Rumble Boxing: Round 2 | Dreamcast | October 23, 2000 | 70 | 74 |
library(lubridate)
data$release_date[1:10]
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"
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”
| name | platform | release_date | meta_score | user_review |
|---|---|---|---|---|
| <chr> | <chr> | <dttm> | <dbl> | <dbl> |
| Mass Effect 3 | Xbox 360 | 2012-03-06 | 93 | 60 |
| Seven: The Days Long Gone | PC | 2017-12-01 | 68 | 74 |
| Zombie Driver: Immortal Edition | Switch | 2019-07-25 | 60 | NA |
| Greak: Memories of Azur | Xbox Series X | 2021-08-17 | 62 | NA |
| Rise of the Argonauts | PC | 2008-12-16 | 59 | 74 |
| The Legend of Heroes: Trails of Cold Steel IV | PlayStation 4 | 2020-10-27 | 81 | 87 |
| Harry Potter and the Order of the Phoenix | Xbox 360 | 2007-06-25 | 68 | 48 |
| Street Fighter EX3 | PlayStation 2 | 2000-10-24 | 64 | 79 |
| Shadowrun | Xbox 360 | 2007-05-29 | 66 | 75 |
| FIFA Soccer 13 | PlayStation Vita | 2012-09-25 | 57 | 41 |
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”
data[1:5,]
| name | platform | release_date | meta_score | user_review |
|---|---|---|---|---|
| <chr> | <chr> | <dttm> | <dbl> | <dbl> |
| The Legend of Zelda: Ocarina of Time | Nintendo 64 | 1998-11-23 | 99 | 91 |
| Tony Hawk's Pro Skater 2 | PlayStation | 2000-09-20 | 98 | 74 |
| Grand Theft Auto IV | PlayStation 3 | 2008-04-29 | 98 | 77 |
| SoulCalibur | Dreamcast | 1999-09-08 | 98 | 84 |
| Grand Theft Auto IV | Xbox 360 | 2008-04-29 | 98 | 79 |
dim(data)
n_distinct(data$name)
data |>
count(game_name = name, name = 'num_platforms') |>
slice(1:10)
| game_name | num_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//Redemption | 1 |
| .hack//Infection Part 1 | 1 |
data |>
count(game_name = name, name = 'num_platforms') |>
count(num_platforms, name = 'num_games')
| num_platforms | num_games |
|---|---|
| <int> | <int> |
| 1 | 8421 |
| 2 | 1949 |
| 3 | 1302 |
| 4 | 419 |
| 5 | 102 |
| 6 | 43 |
| 7 | 15 |
| 8 | 1 |
| 9 | 2 |
data |>
group_by(name) |>
filter(n() >= 8) |>
arrange(name, release_date)
| name | platform | release_date | meta_score | user_review |
|---|---|---|---|---|
| <chr> | <chr> | <dttm> | <dbl> | <dbl> |
| Cars | PC | 2006-06-06 | 73 | 77 |
| Cars | PlayStation 2 | 2006-06-06 | 71 | 87 |
| Cars | GameCube | 2006-06-06 | 71 | 72 |
| Cars | Xbox | 2006-06-06 | 70 | 80 |
| Cars | PSP | 2006-06-06 | 70 | 69 |
| Cars | PlayStation 2 | 2006-06-06 | 54 | 28 |
| Cars | Xbox 360 | 2006-06-06 | 50 | 50 |
| Cars | Xbox 360 | 2006-10-23 | 65 | 72 |
| Cars | Wii | 2006-11-16 | 65 | 70 |
| Madden NFL 06 | PlayStation 2 | 2005-08-08 | 88 | 80 |
| Madden NFL 06 | Xbox | 2005-08-08 | 86 | 68 |
| Madden NFL 06 | GameCube | 2005-08-08 | 86 | 80 |
| Madden NFL 06 | Game Boy Advance | 2005-08-08 | 71 | NA |
| Madden NFL 06 | DS | 2005-08-08 | 66 | 63 |
| Madden NFL 06 | PC | 2005-08-17 | 78 | 68 |
| Madden NFL 06 | PSP | 2005-09-20 | 75 | 79 |
| Madden NFL 06 | Xbox 360 | 2005-11-16 | 74 | 50 |
| Madden NFL 07 | PlayStation 2 | 2006-08-22 | 84 | 82 |
| Madden NFL 07 | Xbox | 2006-08-22 | 83 | 74 |
| Madden NFL 07 | GameCube | 2006-08-22 | 82 | 78 |
| Madden NFL 07 | Xbox 360 | 2006-08-22 | 80 | 60 |
| Madden NFL 07 | PC | 2006-08-22 | 80 | 73 |
| Madden NFL 07 | PSP | 2006-08-22 | 78 | 66 |
| Madden NFL 07 | DS | 2006-08-22 | 70 | 65 |
| Madden NFL 07 | Wii | 2006-11-14 | 81 | 81 |
| Madden NFL 07 | PlayStation 3 | 2006-11-14 | 76 | 47 |
data |>
group_by(name) |>
summarize(distinct_platforms = n_distinct(platform)) |>
count(distinct_platforms, name = 'num_games')
| distinct_platforms | num_games |
|---|---|
| <int> | <int> |
| 1 | 8451 |
| 2 | 1958 |
| 3 | 1278 |
| 4 | 415 |
| 5 | 99 |
| 6 | 40 |
| 7 | 11 |
| 8 | 1 |
| 9 | 1 |
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')
| name | platform | release_date | meta_score | user_review |
|---|---|---|---|---|
| <chr> | <chr> | <dttm> | <dbl> | <dbl> |
| Cars | GameCube | 2006-06-06 | 71.0 | 72.0 |
| Cars | PC | 2006-06-06 | 73.0 | 77.0 |
| Cars | PSP | 2006-06-06 | 70.0 | 69.0 |
| Cars | PlayStation 2 | 2006-06-06 | 62.5 | 57.5 |
| Cars | Wii | 2006-11-16 | 65.0 | 70.0 |
| Cars | Xbox | 2006-06-06 | 70.0 | 80.0 |
| Cars | Xbox 360 | 2006-06-06 | 57.5 | 61.0 |
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'
)
unique(data$platform)
data |>
count(platform, sort = TRUE)
| platform | n |
|---|---|
| <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 |
options(repr.plot.width = 20, repr.plot.height = 20)
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()`).”
data |>
group_by(platform) |>
summarise(cor = cor(meta_score, user_review, use = "complete.obs"))
| platform | cor |
|---|---|
| <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 |
data |>
group_by(platform) |>
summarise(cor = cor(meta_score, user_review, use = "complete.obs")) |>
filter(grepl('PlayStation', platform))
| platform | cor |
|---|---|
| <chr> | <dbl> |
| PlayStation | 0.7456445 |
| PlayStation 2 | 0.6085060 |
| PlayStation 3 | 0.5889878 |
| PlayStation 4 | 0.4456872 |
| PlayStation 5 | 0.4199144 |
| PlayStation Vita | 0.6814964 |
data |>
filter(platform == 'PC') |>
mutate(release_year = year(release_date)) |>
slice(1:10)
| name | platform | release_date | meta_score | user_review | release_year |
|---|---|---|---|---|---|
| <chr> | <chr> | <dttm> | <dbl> | <dbl> | <dbl> |
| .hack//G.U. Last Recode | PC | 2017-11-03 | 69 | 81 | 2017 |
| 007: NightFire | PC | 2002-11-28 | 59 | 61 | 2002 |
| 007: Quantum of Solace | PC | 2008-11-04 | 70 | 63 | 2008 |
| 0RBITALIS | PC | 2015-05-28 | 73 | 73 | 2015 |
| 10 Second Ninja | PC | 2014-03-05 | 72 | 71 | 2014 |
| 11-11: Memories Retold | PC | 2018-11-08 | 73 | 67 | 2018 |
| 112 Operator | PC | 2020-04-23 | 73 | 74 | 2020 |
| 1503 A.D. - The New World | PC | 2003-03-23 | 74 | 76 | 2003 |
| 1701 A.D. | PC | 2006-11-06 | 79 | 77 | 2006 |
| 1954: Alcatraz | PC | 2014-03-11 | 58 | 63 | 2014 |
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()`).”
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"))
| release_year | cor |
|---|---|
| <dbl> | <dbl> |
| 2000 | 0.3987361 |
| 2001 | 0.6546850 |
| 2002 | 0.5269442 |
| 2003 | 0.5938655 |
| 2004 | 0.4686154 |
| 2005 | 0.5750785 |
| 2006 | 0.5839964 |
| 2007 | 0.7127208 |
| 2008 | 0.6538982 |
| 2009 | 0.6772034 |
| 2010 | 0.5755253 |
| 2011 | 0.6349635 |
| 2012 | 0.6708502 |
| 2013 | 0.6047175 |
| 2014 | 0.5605304 |
| 2015 | 0.5237161 |
| 2016 | 0.4260962 |
| 2017 | 0.4271391 |
| 2018 | 0.4634149 |
| 2019 | 0.4222958 |
| 2020 | 0.4150902 |
| 2021 | 0.2937798 |
library(confintr)
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]
)
cors_with_conf_intervals
| release_year | cor | conf_lower | conf_upper |
|---|---|---|---|
| <dbl> | <dbl> | <dbl> | <dbl> |
| 2000 | 0.3987361 | 0.2318216 | 0.5428424 |
| 2001 | 0.6546850 | 0.5508174 | 0.7385832 |
| 2002 | 0.5269442 | 0.4065227 | 0.6293698 |
| 2003 | 0.5938655 | 0.4898620 | 0.6812026 |
| 2004 | 0.4686154 | 0.3375917 | 0.5818251 |
| 2005 | 0.5750785 | 0.4614497 | 0.6701439 |
| 2006 | 0.5839964 | 0.4786151 | 0.6727917 |
| 2007 | 0.7127208 | 0.6271870 | 0.7812686 |
| 2008 | 0.6538982 | 0.5540041 | 0.7352301 |
| 2009 | 0.6772034 | 0.5901155 | 0.7487119 |
| 2010 | 0.5755253 | 0.4587409 | 0.6727644 |
| 2011 | 0.6349635 | 0.5412895 | 0.7130694 |
| 2012 | 0.6708502 | 0.5883002 | 0.7395623 |
| 2013 | 0.6047175 | 0.5234282 | 0.6750983 |
| 2014 | 0.5605304 | 0.4713620 | 0.6383550 |
| 2015 | 0.5237161 | 0.4363536 | 0.6012964 |
| 2016 | 0.4260962 | 0.3300549 | 0.5134062 |
| 2017 | 0.4271391 | 0.3256785 | 0.5188741 |
| 2018 | 0.4634149 | 0.3617637 | 0.5541765 |
| 2019 | 0.4222958 | 0.3162759 | 0.5178971 |
| 2020 | 0.4150902 | 0.3142352 | 0.5066802 |
| 2021 | 0.2937798 | 0.1580356 | 0.4186260 |
options(repr.plot.width = 20, repr.plot.height = 10)
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))
library(ggridges)
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()`).”