Problem 1

#install.packages("plotly")
library(plotly)
library(dslabs)
library(ggplot2)
library(tidyverse)

results <- read.csv("fl_results.csv")

results %>%
  plot_ly(x = ~Precincts, y = ~CanVotes, hoverinfo = "text", text = ~CountyName) %>%
  add_markers(color = ~CountyName) %>%
  layout(xaxis = list(title = "Number of Precincts"),
         yaxis = list(title = "Number of Candidate Votes"),
         title = "Florida Election Results for Rick Scott")

This graph is showing the election results for one Florida candidate, Rick Scott. The x axis is the number of precincts in each county. The y axis is the number of votes for the candidate. Each county is represented by a different color on the right side of the graph. When hovering over each point on the graph, the name of each county in Florida will be shown in corresponding colors. This is helpful for the reader because they are able to easily see which results belong to which county without having to look at the legend and match the colors. I did not have any challenges when making this plot because counties were the only grouping variable that made sense in this data set.

Problem 2

library(plotly)
library(dslabs)
library(ggplot2)
library(tidyverse)

sales <- read.csv("vgsales.csv")

sales %>%
  plot_ly(x = ~NA_Sales, y = ~EU_Sales) %>%
  add_markers(frame = ~Year, color = ~Genre) %>%
  layout(xaxis = list(title = "North American Sales"),
         yaxis = list(title = "European Sales"),
         title = "Video Game Sales by Genre") %>%
  animation_slider(currentvalue = list(prefix=NULL,
                                       font = list(color = "black",
                                                   size = 40)))

This graph is showing video game sales over the span of 40 years in different parts of the world. The x axis is North American sales and the y axis is European sales. The genres of video games are represented by different colors shown on the right side of the graph. When hovering over each point on the graph, the reader can see which genre each result is for. For most of the video games, there are more sales in North America than in Europe. Specifically, the genres with increased interest in North America include platform and puzzle games. Action games were about equally popular in both North America and Europe. The games that were more popular in Europe typically fell into the miscellaneous category. A challenge with making this plot was figuring out which variable to use when grouping the results. Other options for grouping that I explored include ratings and publishers. However, genres was the variable that made the most sense when looking for patterns.