Task 1: Interactive plots

library(tidyverse)
library(plotly)
library(scales)     

unemployment <- read.csv("C:/CS134/Week7/unemployment.csv")


# Load data here
unemp_ave<-unemployment%>%
  filter(year%in%c(2010, 2016))%>%
  group_by(division, year, state)%>%
  summarize(ave_unemp = mean(unemployment))%>%
  ungroup()
## `summarise()` has grouped output by 'division', 'year'. You can override using
## the `.groups` argument.
ave_plot<-unemp_ave%>%
ggplot(aes(y = division , x = ave_unemp, color = year)) +
  geom_point(aes(text=state),position = position_jitter(width = 0, height = 0.15, seed = 1234)) +
  guides(color = "none") +
    theme_bw()
## Warning in geom_point(aes(text = state), position = position_jitter(width = 0,
## : Ignoring unknown aesthetics: text
ave_plot

ggplotly(ave_plot, tooltip = "text")
interactive_plot <- ggplotly(ave_plot, tooltip = "text")
htmlwidgets::saveWidget(interactive_plot, "ave_plot.html")
  1. Make a plot. Any kind of plot will do (though it might be easiest to work with geom_point()).

  2. Make the plot interactive with ggplotly().

  3. Make sure the hovering tooltip is more informative than the default.

Good luck and have fun!