The csv file bgg.csv contains 999 board games from the website boardgamegeek.com. There are 10 variables. The relevant variables are:
In the code chunk below, load the tidyverse package and read in the csv file and save it as bgg
pacman::p_load(tidyverse)
bgg <- read.csv("bgg.csv")
Create the plot in Brightspace that has:
# Create the graph below:
# Setting the data and x & y aesthetics
ggplot(
data = bgg,
mapping = aes(x = rating,
y = kickstarted)
) +
# Creating the boxplots and filling in with the correct colors
geom_boxplot(
fill = "#F46E52",
color = "#440864"
) +
# Changing the default theme
theme_bw() +
# Changing the x & y labels and adding a title
labs(
x = "Average User Rating",
y = "Was the Game on Kickstarter?",
title = "Board Games on Board Game Geek"
) +
# Changing the grid lines on the x-axis
scale_x_continuous(
breaks = 1:10,
minor_breaks = NULL
) +
# Centering the title
theme(plot.title = element_text(hjust = 0.5))
For question 2, you’ll be examining the association between user average rating (rating) and play time (playtime) with a scatter plot
Start by creating the blank graph seen in Brightspace. The orange color for the title uses the same hex code as the orange in question 1. Make sure the labels, title, caption, and theme match. Save the blank graph as gg_bgg and have it appear in your solutions.
# Mapping playtime to x-axis and rating to the y-axis
ggplot(data = bgg,
mapping = aes(x = playtime,
y = rating)
) +
# Adding a title and changing labels
labs(
title = "Board Game Geek Ratings",
caption = "Data: Kaggle.com",
x = "Manufacturer Estimated Play Time (Minutes)",
y = NULL
) +
theme_bw() +
# Centering the title and changing the color
theme(
plot.title = element_text(hjust = 0.5,
color = "#F46E52",
size = 16)
) ->
gg_bgg
gg_bgg
Using gg_bgg, the appropriate geoms
, and other
functions, create the graph seen in Brightspace. Save it as
gg_rating_scatter and have it appear in the
solutions.
gg_bgg +
# Creating the scatterplot by adding points to the blank graph
geom_point(mapping = aes(color = age_rec)) +
# Adding an orange-red trend line
geom_smooth(
formula = y ~ x,
method = "loess",
color = "tomato",
se = F
) +
# Changing the color scheme from gradient to viridis
# and changing the tick-marks on the color bar
scale_color_continuous(
type = "viridis",
breaks = c(7, 10, 13, 16)
) +
# Changing the labels for the color guide
labs(color = "Min Age") ->
gg_rating_scatter
gg_rating_scatter
Using gg_rating_scatter, create the graph seen in Brightspace. Briefly describe 3 different insights you can reach from the graph!
# Using facet_wrap() to make multiple scatterplots, one for each category
gg_rating_scatter +
facet_wrap(facets = ~ category)