Task 1: Reflection

This is a very interesting session that opens the door to the new world of interactive graphs. I consider session as a primer to different quite accessible ways to tools to achieve this end. Although I did not have the time to go over each one in depth, it is nice to know they are there and once I have specific need to make anything interactive for something like a webpage, I would explore more on the more advanced tools of flexdashboard and Shiny.

In terms of doing plotly in R, one new aspect of coding with R that we learn is that you can use a false aesthetic in ggplot and pass that false layer of aesthatic to some other functions as ggplotly().

Task 2: Interactive plots

library(tidyverse)
library(plotly)
library(gapminder)
library(scales)
## sub set for 2007
gapminder2002 <- gapminder %>% 
  filter(year == 2002)

## basic plot
plot_base <- ggplot(gapminder2002, aes(x = lifeExp, y = continent,
 size = pop, color = country)) +
 geom_point(aes(text = country), alpha = 0.7, 
            position = position_jitter(width = 0, height = 0.2, 
                                       seed = 20210705)) +
 scale_size(range = c(2, 8)) +
 guides(size = "none", color = "none") +
 scale_color_viridis_d(option = "plasma") +
 labs(title = "Country Life Expectancy by Continent in 2002")

plot_base

ggplotly(plot_base, tooltip = "text")