This report explores the Kaggle avocado price dataset, which contains weekly average prices and sales volume for avocados across U.S. regions from 2015-2018, split by type (conventional vs. organic).
avocado <- read_csv("avocado.csv")
# Clean up: parse date, drop the stray index column if present
avocado <- avocado %>%
rename(index = 1) %>%
select(-index) %>%
mutate(Date = as.Date(Date))
glimpse(avocado)
## Rows: 18,249
## Columns: 13
## $ Date <date> 2015-12-27, 2015-12-20, 2015-12-13, 2015-12-06, 2015-1…
## $ AveragePrice <dbl> 1.33, 1.35, 0.93, 1.08, 1.28, 1.26, 0.99, 0.98, 1.02, 1…
## $ `Total Volume` <dbl> 64236.62, 54876.98, 118220.22, 78992.15, 51039.60, 5597…
## $ `4046` <dbl> 1036.74, 674.28, 794.70, 1132.00, 941.48, 1184.27, 1368…
## $ `4225` <dbl> 54454.85, 44638.81, 109149.67, 71976.41, 43838.39, 4806…
## $ `4770` <dbl> 48.16, 58.33, 130.50, 72.58, 75.78, 43.61, 93.26, 80.00…
## $ `Total Bags` <dbl> 8696.87, 9505.56, 8145.35, 5811.16, 6183.95, 6683.91, 8…
## $ `Small Bags` <dbl> 8603.62, 9408.07, 8042.21, 5677.40, 5986.26, 6556.47, 8…
## $ `Large Bags` <dbl> 93.25, 97.49, 103.14, 133.76, 197.69, 127.44, 122.05, 5…
## $ `XLarge Bags` <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0…
## $ type <chr> "conventional", "conventional", "conventional", "conven…
## $ year <dbl> 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2…
## $ region <chr> "Albany", "Albany", "Albany", "Albany", "Albany", "Alba…
avocado %>%
group_by(type) %>%
summarise(
avg_price = mean(AveragePrice),
avg_volume = mean(`Total Volume`),
.groups = "drop"
)
## # A tibble: 2 × 3
## type avg_price avg_volume
## <chr> <dbl> <dbl>
## 1 conventional 1.16 1653213.
## 2 organic 1.65 47811.
avocado %>%
group_by(Date, type) %>%
summarise(AveragePrice = mean(AveragePrice), .groups = "drop") %>%
ggplot(aes(x = Date, y = AveragePrice, color = type)) +
geom_line(linewidth = 0.8) +
labs(
title = "Average Avocado Price Over Time",
subtitle = "Conventional vs. Organic",
x = "Date",
y = "Average Price (USD)",
color = "Type"
) +
theme_minimal()
This shows organic avocados consistently priced higher than conventional, with both following similar seasonal price swings.
avocado %>%
filter(!region %in% c("TotalUS", "West", "SouthCentral", "Northeast",
"Southeast", "GreatLakes", "Midsouth", "Plains",
"California", "WestTexNewMexico")) %>%
group_by(region) %>%
summarise(total_volume = sum(`Total Volume`), .groups = "drop") %>%
arrange(desc(total_volume)) %>%
slice_head(n = 10) %>%
ggplot(aes(x = reorder(region, total_volume), y = total_volume)) +
geom_col(fill = "darkgreen") +
coord_flip() +
labs(
title = "Top 10 Regions by Total Avocado Volume",
x = "Region",
y = "Total Volume Sold"
) +
theme_minimal()
Los Angeles and other major metro regions dominate total avocado volume compared to smaller markets.
Organic avocados command a price premium over conventional ones throughout the dataset, and sales volume is heavily concentrated in a handful of large metro regions.