Instacart Data Plots

data("instacart")

Plot 1: Snack Purchases

yax_title = list(title = "Number of Purchases")
xax_title = list(title = "Types of Snacks")

snack_bar = 
  instacart %>%  
  filter(department == "snacks") %>% 
  count(aisle) %>% 
  mutate(
    aisle = fct_reorder(aisle, n)
    ) %>% 
  plot_ly(x = ~aisle, y = ~n, color = ~aisle, colors = "viridis", type = "bar") %>% 
  layout(yaxis = yax_title, xaxis = xax_title)

snack_bar

Plot 2: Pet Food Order Information

yord_title = list(title = "Order Number")
xord_title = list(title = "Days Since Prior Order")

pet_time = 
  instacart %>% 
  filter(department == "pets") %>%
  plot_ly(x = ~days_since_prior_order, y = ~order_number, 
          color = ~aisle, colors = "viridis", type = "scatter", symbol = ~aisle) %>% 
  layout(yaxis = yord_title, xaxis = xord_title) 

pet_time

Plot 3: Snack Orders by Time

y_title = list(title = "Number of Snack Orders")
x_title = list(title = "Hour of the Day (Military Time)")

snack_hour = 
  instacart %>% 
  filter(department == "snacks") %>% 
  group_by(order_hour_of_day) %>%
  plot_ly(
    x = ~order_hour_of_day, 
    colors = "viridis", 
    type = "histogram"
    ) %>% 
   layout(yaxis = y_title, xaxis = x_title)

snack_hour