Project 1 DATA 110 Video Games Data Analysis

Project Overview

This project explores the relationship between the review score, sales, and provides data on the publishers.

Data Source

The data set I’m using for this project is sourced from “CORGIS Dataset Project” (https://corgis-edu.github.io/corgis/csv/video_games/). This data was collected by Dr. Joe Cox, created 4/13/2017. This data contains information about sales, publisher, playtime, and more.

Research Question

  1. Is there a relationship between game sales and their review score out of 100?

Variables I’m Focusing On

There are 36 variables. But, the variables I will be focusing on for this project are:

“Metrics.Review Score”: The review score on the game (scored out of 100).

“Metadata.Publishers”: Publisher of the game

“Metrics.Sales”: Total sales of the game (scale of millions)

Uploading Libraries and Data set

library(readr)
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.2.1     ✔ purrr     1.2.2
✔ forcats   1.0.1     ✔ stringr   1.6.0
✔ ggplot2   4.0.3     ✔ tibble    3.3.1
✔ lubridate 1.9.5     ✔ tidyr     1.3.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
library(dplyr)
library(ggplot2)
library(plotly)

Attaching package: 'plotly'

The following object is masked from 'package:ggplot2':

    last_plot

The following object is masked from 'package:stats':

    filter

The following object is masked from 'package:graphics':

    layout
video_games_data <- read_csv("video_games.csv")
Rows: 1212 Columns: 36
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr  (5): Title, Metadata.Genres, Metadata.Publishers, Release.Console, Rele...
dbl (25): Features.Max Players, Metrics.Review Score, Metrics.Sales, Metrics...
lgl  (6): Features.Handheld?, Features.Multiplatform?, Features.Online?, Met...

ℹ 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.
# checking head of data set
# head(video_games_data)
names(video_games_data) <- gsub(" ", "_", names(video_games_data))

Cleaning Data Set

# make variables lowercase

names(video_games_data) <- tolower(names(video_games_data))
# focusing on my specific variables, so it doesn't have to keep loading all variables

key_variables <- video_games_data |>
  select(metadata.publishers, metrics.review_score, metrics.sales)

head(key_variables)
# A tibble: 6 × 3
  metadata.publishers metrics.review_score metrics.sales
  <chr>                              <dbl>         <dbl>
1 Nintendo                              85          4.69
2 Ubisoft                               89          0.56
3 Nintendo                              81          0.54
4 Sony                                  81          0.49
5 Activision                            61          0.45
6 EA                                    67          0.41
# find the names of all the publishers

publishers <- key_variables %>%
  distinct(metadata.publishers)

print(publishers, n=33)
# A tibble: 32 × 1
   metadata.publishers 
   <chr>               
 1 Nintendo            
 2 Ubisoft             
 3 Sony                
 4 Activision          
 5 EA                  
 6 Namco               
 7 Konami              
 8 <NA>                
 9 Sega                
10 Capcom              
11 Capcom,Rockstar     
12 Activision,Konami   
13 Rockstar            
14 THQ                 
15 Microsoft           
16 Activision,Sony     
17 2K                  
18 Atari               
19 SquareEnix          
20 EA,Namco            
21 Namco,Sony          
22 Midway              
23 Eidos               
24 Sony,Ubisoft        
25 Nintendo,SquareEnix 
26 EA,Sony             
27 Microsoft,SquareEnix
28 Atari,Namco         
29 Nintendo,Sega       
30 Capcom,Nintendo     
31 Disney              
32 Namco,Ubisoft       

Diagnostic Plot

ggplot(key_variables, aes(x=metrics.review_score, y=metrics.sales))+
  geom_point() +
  geom_smooth(method = "lm")
`geom_smooth()` using formula = 'y ~ x'

# There seems to be a slight positive trend with a couple of outliers. This distribution would be easier to see using a histogram. 

ggplot(key_variables, aes(x = metrics.review_score)) +
  geom_histogram(fill = "pink", color = "white", bins = 15) +
  theme_minimal() +
  labs(title = "Distribution of Review Scores ")

Visualizing the data

# I want to include publisher data to also see if there's a correlation between that and sales and score. Since publisher data as the x or y axis can get overcrowded, I'm opting for a colored option. Additonally, this makes it more clear because publishers are a qualitative variable, while sales and score are quantitative. 




ggplot(key_variables, aes(x = metrics.review_score, y = metrics.sales, color = factor(metadata.publishers))) +
  geom_point() +
  geom_smooth(method = "lm", se = FALSE, color = "black", linetype = "dotted", size = 0.5) +
  
  
  labs(
    title = "Analysis of Video Game Sales and Review Scores",
    subtitle = "Comparing games by their publisher",
    x = "Review Score (Out of 100)",
    y = "Game Sales (Millions)",
    color = "Publisher",
    caption = "Source: CORGIS Dataset Project"
  ) +
  
  theme_gray() +
  theme(
    legend.position = "right",
    legend.title = element_text(size = 7, face = "bold"), 
    legend.text = element_text(size = 6))
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.
`geom_smooth()` using formula = 'y ~ x'

Revising Visualization (Final Visualization)

I noticed that the graph gets too polluted near the bottom. To remedy this problem, I will be making the y-axis scale by log instead. I will also lower the points opacity to make sure overlapping points are clear and making the publisher legend smaller to allow more room for the graph.

ggplot(key_variables, aes(x = metrics.review_score, y = metrics.sales, color = factor(metadata.publishers))) +
  geom_point(size = 1.5, alpha = 0.5) +
  geom_smooth(method = "lm", se = FALSE, color = "black", linetype = 2, size = 1) +
  scale_fill_brewer(palette = "Spectral") +
  scale_y_log10() +

  
  labs(
    title = "Analysis of Review SCores vs. Video Games Sales",
    subtitle = "Comparing games by their publisher",
    x = "Review Score (Out of 100)",
    y = "Game Sales (log 10)",
    color = "Publisher",
    caption = "Source: CORGIS Dataset Project"
  ) +
  
  theme_minimal() +
  theme(
    legend.position = "right",
    legend.title = element_text(size = 6, face = "bold"), 
    legend.text = element_text(size = 6),
    legend.key.size = unit(0.3, "cm"), 
    legend.spacing.y = unit(0.1, "cm"))
`geom_smooth()` using formula = 'y ~ x'

# I notice that are some clear outliers on the graph, but that is to be expected since the data set we are using is so large.

Linear Regression Analysis

# check for residuals, r values, and r-squared
fit_games <- lm(metrics.review_score ~ metrics.sales, data = key_variables)

summary(fit_games)

Call:
lm(formula = metrics.review_score ~ metrics.sales, data = key_variables)

Residuals:
    Min      1Q  Median      3Q     Max 
-61.897  -7.719   1.572   9.551  25.163 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept)    67.0133     0.3928  170.61   <2e-16 ***
metrics.sales   3.6073     0.3323   10.85   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 12.37 on 1210 degrees of freedom
Multiple R-squared:  0.08873,   Adjusted R-squared:  0.08797 
F-statistic: 117.8 on 1 and 1210 DF,  p-value: < 2.2e-16
# visualize linear regressions
par(mfrow = c(2, 2))
plot(fit_games)

Important Notes

Adjusted R-squared: 0.08797

P-value: < 2.2e-16

Estimated Equation:

Review score = 67.0133 ( y-intercept) + 3.6073(sales)

I found this equation using the data from “summary(fit_games)” coefficients.

Linear Regression Analysis

The regression analysis shows a strong positive relationship between metric review scores and game sales. The p-value for this model is less than 0.001, showing that this relationship is statistically significant. However, the adjusted R-squared value is 0.08797, which means the model only accounts for 8.8% of the dependent variable. This may be because there’s a large number of other factors that go into metric sales, compared to just metric review scores. Some other factors could be popularity, game length, and many others. There seems to be a positive pattern, but it can’t fully be explained using the variables from our model.

I used 2 diagnostic plots to get a better sense of the data. The first diagnostic graph I used is a scatter plot. The scatter plot showed there was a positive correlation, however it seemed very crowded and confusing. This prompted me to take note of changing the y-axis. So, I did another diagnostic graph that focused on the distribution of metric scores.

Cleaning Conclusion

I had to do a few actions to clean up the data set. The first thing I did was to make all the variables lowercase. I did this by using the names function and tolower. Then, I made a new name called key_variables to only focus on the variables of the data set I want to focus on. I did this because there were a large number of other variables that wouldn’t be useful, so it’d be easier for the program and myself to only have R load the ones I need.

Visualization Conclusion

For my visualization, I did a scatter plot. The scatter plot represents the relationship between review scores (out of 100) and video game sales. It was crucial to make video game sales on log scale in order to make the graph easier to understand. I added a linear regression line to show the upward trend on the model.

One interesting surprise I ran into with this visualization was the wide scale of variation between the data points. Although there is an upward trend, there are a lot of data points that are really far from the linear regression line. For example, if you look at x=80, the game sales can vary from very low like 0.01 and to 10.0. That goes to show there are definitely other factors that impact game sales, and the relationship isn’t exact.

Challenges and Future Studies

One challenge I faced was the range of the y-axis. As you can see with my first visualization, the points are overcrowded and hard to understand. I found that making the scale on log was the best option, but it took trial and error. Another challenge I faced was the size of the legend. At first, the legend was too big and obstructed the graph. It took many attempts to see which element and text size works best to showcase both the legend and the graph appropriately.

If I were to expand on this project, I would look at a larger set of variables. For this project, I only focused on sales, review scores, and publisher. However, this data set contains more variables than just that. As we’ve seen from the R-squared value, the model I made is only estimated to account for 8.8% of game sales from the review scores. So, I would want to see what variables are primarily involved in game sales. Additionally, since this data set is only between 2004 and 2010, I would want to expand the data to include more recent years to see if trends have changed.