Load Data

games <- read.csv("Video_Games_Sales_as_at_22_Dec_2016.csv", stringsAsFactors = FALSE)

# Keep only rows with usable numeric data
games <- games %>%
  filter(!is.na(Year_of_Release), Year_of_Release != "N/A", !is.na(Global_Sales))

games$Year_of_Release <- as.numeric(games$Year_of_Release)
games <- games %>% filter(!is.na(Year_of_Release))

Sample 50% of the Data

Per the request, only half of the dataset is used for the graphs below.

set.seed(42)  # for reproducibility
games_sample <- games %>% sample_frac(0.5)

nrow(games)         # original row count
## [1] 16450
nrow(games_sample)  # sampled row count (50%)
## [1] 8225

Graph 1: Dotted Graph — Global Sales Over Release Year

A scatter plot with a dotted trend line showing global sales by year of release.

yearly_avg <- games_sample %>%
  group_by(Year_of_Release) %>%
  summarise(Avg_Global_Sales = mean(Global_Sales, na.rm = TRUE))

ggplot(yearly_avg, aes(x = Year_of_Release, y = Avg_Global_Sales)) +
  geom_point(color = "steelblue", size = 2) +
  geom_line(linetype = "dotted", color = "darkred", linewidth = 1) +
  labs(
    title = "Average Global Sales by Year of Release (50% Sample)",
    x = "Year of Release",
    y = "Average Global Sales (millions)"
  ) +
  theme_minimal()

Graph 2: Pie Chart — Sales by Genre

A pie chart showing the share of total global sales by genre.

genre_sales <- games_sample %>%
  group_by(Genre) %>%
  summarise(Total_Sales = sum(Global_Sales, na.rm = TRUE)) %>%
  arrange(desc(Total_Sales))

ggplot(genre_sales, aes(x = "", y = Total_Sales, fill = Genre)) +
  geom_bar(stat = "identity", width = 1) +
  coord_polar(theta = "y") +
  labs(title = "Global Sales Share by Genre (50% Sample)") +
  theme_void() +
  theme(legend.title = element_blank())

Summary

This report used a random 50% sample of the original video games sales dataset (8225 of 16450 rows) to generate:

  1. A dotted line graph of average global sales by release year.
  2. A pie chart of global sales distribution by genre.