library(ggplot2)
library(dplyr)
avocado <- read.csv("avocado (1).csv")
names(avocado) <- trimws(names(avocado))
ggplot(avocado, aes(x = type, y = average_price, fill = type)) +
geom_boxplot() +
facet_wrap(~year) +
labs(
title = "Hass Avocado Prices by Type and Year",
x = "Avocado Type",
y = "Average Price"
) +
theme_minimal()
Organic Hass avocados generally have higher prices than conventional avocados. This can help businesses make better pricing and promotion decisions.
avocado <- avocado %>%
mutate(dollar_sales = average_price * total_volume)
top10 <- avocado %>%
group_by(geography) %>%
summarise(total_sales = sum(dollar_sales), .groups = "drop") %>%
arrange(desc(total_sales)) %>%
slice_head(n = 10)
ggplot(top10,
aes(x = reorder(geography, total_sales),
y = total_sales / 1000000)) +
geom_col(fill = "steelblue") +
coord_flip() +
labs(
title = "Top 10 Cities by Hass Avocado Dollar Sales",
x = "City",
y = "Sales ($ Millions)"
) +
theme_minimal()
The second figure shows which cities generate the highest avocado dollar sales. Businesses can use this information to decide where to focus inventory, advertising, and promotions.