library(gsheet)
library(googlesheets4)
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
# Read in the Data
URL <- "https://docs.google.com/spreadsheets/d/1Ap5h86minzUi-wOqE9SREHGCa_nGTDPspa7V5WFDnEI/edit?usp=sharing"
DATA <- gsheet2tbl(URL)
# Get rid of the Timestamp Column
DATA <- DATA[,-1]
# Rename the columns for easier coding
colnames(DATA) <- c("StudentPlaying", "Time", "Experience", "ControllerType", "Course", "CC", "NumItemsUsed", "CharacterPlayed", "CoinCount", "SwitchScreen", "PlaceInRace")
# Get rid of potential duplicates by putting them in all capital letters
DATA$CharacterPlayed <- toupper(DATA$CharacterPlayed)
# Filter out rows where either CoinCount or PlaceInRace is NA
DATA <- na.omit(DATA[c("CoinCount", "PlaceInRace", "ControllerType")])
# Define Pokemon-themed color palette
pokemon_palette <- c("#FFCB05", "#3A75C4", "#B8B8B8", "#FD5E0F")
# Plot
p <- ggplot(DATA, aes(x = CoinCount, y = PlaceInRace, color = ControllerType)) +
geom_point(size = 3) +
geom_smooth(method = "lm", se = FALSE, color = "black") + # Add line of best fit
scale_color_manual(values = pokemon_palette) +
labs(title = "Scatter Plot of CoinCount vs. PlaceInRace",
x = "CoinCount",
y = "PlaceInRace",
color = "Controller Type") +
theme_minimal() +
theme(legend.position = "right")
# Make the plot interactive using Plotly
ggplotly(p)
## `geom_smooth()` using formula = 'y ~ x'