Skip to content
Visualizing Video Game Sales Data with ggplot2 in R
Visualizing Video Games Sales Data
In this code-along, we'll use ggplot2 to visualize sales of popular video games in North America, Europe, and Japan.
The dataset used here is a subset of the "Video Games Sales Data" dataset available in Workspace. The dataset was originally sourced from Kaggle.
- Every video game in this dataset has at least 100k global sales.
- We'll look at games from some of the most popular desktop consoles in the 4th to 8th console generations.
- Since the dataset is from Kaggle, the trustworthiness is questionable. This is for fun, not for real-world business decisions.
Loading packages
In this code-along, we'll use readr
to import the dataset, dplyr
and forcats
to manipulate the data, and ggplot2
to visualize the data.
Instructions
- Load the
readr
,dplyr
,forcats
andggplot2
packages.
# Load readr, dplyr, forcats, ggplot2
library(readr)
library(dplyr)
library(forcats)
library(ggplot2)
The following lines of code make it easier to see the visualizations during the webinar.
# Set the default figure font size to 20 (and use the gray theme for plot colors)
theme_set(theme_gray(20))
# Display plots in the workspace with a width of 10 inches and a height of 7 inches
opts <- options(repr.plot.width = 10, repr.plot.height = 8)
Import the dataset
The dataset is stored in a CSV file named vgsales.csv
in the data
directory.
Instructions
- Read the CSV file "data/vgsales.csv". Assign the result to
vgsales
. - Glimpse at the column information in
vgsales
.
# Load necessary library
library(dplyr)
# Read the CSV file "data/vgsales.csv"
vgsales <- read.csv("data/vgsales.csv")
# Glimpse the result
glimpse(vgsales)
Data dictionary