Instacart
data graphs using plotly
Load necessary data.
data("instacart")
instacart =
instacart %>%
select(product_id, product_name, aisle, department, reordered)
instacart %>%
count(product_name) %>%
mutate(rank = min_rank(desc(n))) %>%
filter(rank < 20) %>%
mutate(product_name = fct_reorder(product_name, desc(n))) %>%
plot_ly(
x = ~product_name, y = ~n,
color = ~product_name, type = "bar")
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors
instacart %>%
count(aisle) %>%
filter(n > 20000) %>%
mutate(
aisle = factor(aisle),
aisle = fct_reorder(aisle, n)
) %>%
plot_ly(
x = ~aisle, y = ~n, alpha = 1,
type = "scatter", mode = "markers"
)
instacart %>%
group_by(department) %>%
filter(reordered != 0) %>%
plot_ly(
labels = ~department, values = ~reordered, type = "pie"
)