load data

library(tidyverse)
library(dplyr)
library(p8105.datasets)
library(plotly)

knitr::opts_chunk$set(
    fig.width = 6, 
  fig.asp = .6,
  out.width = "90%"
)
theme_set(theme_minimal() + theme(legend.position = "bottom"))
options(
  ggplot2.continuous.colour = "viridis",
  ggplot2.continuous.fill = "viridis"
)
scale_colour_discrete = scale_colour_viridis_d
scale_fill_discrete = scale_fill_viridis_d
data("instacart")
instacart = 
  instacart %>%
  select(order_id, product_id, order_number, order_hour_of_day,product_name, department) %>% 
  filter(product_id <= 10)
instacart
## # A tibble: 247 x 6
##    order_id product_id order_number order_hour_of_day product_name    department
##       <int>      <int>        <int>             <int> <chr>           <chr>     
##  1     5368         10           33                14 Sparkling Oran… beverages 
##  2     6695          1           29                 1 Chocolate Sand… snacks    
##  3    14172         10           30                17 Sparkling Oran… beverages 
##  4    48361          1            5                14 Chocolate Sand… snacks    
##  5    50978         10            6                 8 Sparkling Oran… beverages 
##  6    63399         10           10                17 Sparkling Oran… beverages 
##  7    63770          1            7                 6 Chocolate Sand… snacks    
##  8    72425          3           22                16 Robust Golden … beverages 
##  9    75339          1            6                13 Chocolate Sand… snacks    
## 10    80409         10            9                15 Sparkling Oran… beverages 
## # … with 237 more rows

scartter plot

instacart %>% 
  plot_ly(x = ~product_name, y = ~order_hour_of_day, color = ~department,type = "scatter", mode = "markers")

boxplot

instacart %>% 
  plot_ly(x = ~product_name, y = ~order_hour_of_day, color = ~department,type = "box", colors = "viridis")

bar plot

instacart %>% 
  plot_ly(x = ~product_name, y = ~order_hour_of_day, color = ~department,type = "bar", colors = "viridis")