loading and tidying the instacart dataset

# loading dataset
data("instacart")

# tidying dataset 
instacart_df =
  instacart %>% 
  janitor::clean_names() %>% 
  filter(
    department %in% c("frozen"), 
    order_dow == 6
  )

making a barplot

instacart_df %>% 
  count(aisle) %>% 
  mutate(aisle = fct_reorder(aisle, n)) %>% 
  plot_ly(x = ~aisle, y = ~n, color = ~aisle, type = "bar", colors = "viridis") %>% 
  layout(xaxis = list(title = "Frozen food aisle"),
         yaxis = list(title = "Number of items ordered"))

making a boxplot

instacart_df %>% 
  mutate(aisle = fct_reorder(aisle, order_hour_of_day)) %>% 
  plot_ly(y = ~order_hour_of_day, color = ~aisle, type = "box", colors = "viridis") %>% 
  layout(xaxis = list(title = "Frozen food aisle"),
         yaxis = list(title = "Order hour of the day"))

making a histogram

instacart_df %>% 
  plot_ly(x = ~days_since_prior_order, color = ~aisle, type = "histogram", colors = "viridis") %>% 
  layout(x = "Days since prior order",
         y = "Count")


Click here to return to the main page.