Introduction

This analysis examines Hass avocado prices, sales volume, avocado type, and geographic sales. The purpose is to understand avocado pricing patterns and identify cities with the highest sales.

library(ggplot2)
library(dplyr)

data <- read.csv("avocado (1).csv", fileEncoding = "UTF-8-BOM")

names(data)[names(data) == "average_price "] <- "average_price"

summary(data)
##         date       average_price    total_volume            type      
##  Length   :12628   Min.   :0.500   Min.   :    253   Length   :12628  
##  N.unique :  154   1st Qu.:1.100   1st Qu.:  15733   N.unique :    2  
##  N.blank  :    0   Median :1.320   Median :  94806   N.blank  :    0  
##  Min.nchar:    8   Mean   :1.359   Mean   : 325259   Min.nchar:    7  
##  Max.nchar:   10   3rd Qu.:1.570   3rd Qu.: 430222   Max.nchar:   12  
##                    Max.   :2.780   Max.   :5660216                    
##       year          geography        Mileage    
##  Min.   :2017   Length   :12628   Min.   : 111  
##  1st Qu.:2018   N.unique :   41   1st Qu.:1097  
##  Median :2019   N.blank  :    0   Median :2193  
##  Mean   :2019   Min.nchar:    5   Mean   :1911  
##  3rd Qu.:2020   Max.nchar:   20   3rd Qu.:2632  
##  Max.   :2020                     Max.   :2998
str(data)
## 'data.frame':    12628 obs. of  7 variables:
##  $ date         : chr  "2017/12/3" "2017/12/3" "2017/12/3" "2017/12/3" ...
##  $ average_price: num  1.39 1.44 1.07 1.62 1.43 1.58 1.14 1.77 1.4 1.88 ...
##  $ total_volume : int  139970 3577 504933 10609 658939 38754 86646 1829 488588 21338 ...
##  $ type         : chr  "conventional" "organic" "conventional" "organic" ...
##  $ year         : int  2017 2017 2017 2017 2017 2017 2017 2017 2017 2017 ...
##  $ geography    : chr  "Albany" "Albany" "Atlanta" "Atlanta" ...
##  $ Mileage      : int  2832 2832 2199 2199 2679 2679 827 827 2998 2998 ...

Average Avocado Price

ggplot(data, aes(x = average_price, fill = type)) +
  geom_histogram(bins = 30, color = "black") +
  labs(
    title = "Frequency of Average Avocado Prices",
    x = "Average Price",
    y = "Frequency",
    fill = "Type"
  ) +
  theme_minimal()

Question 1

The lowest average avocado price in the dataset was $0.50. The highest average price was $2.78. Therefore, the price range was $0.50 to $2.78.

The Hass Avocado Board’s research benefits growers, retailers, marketers, importers, distributors, health professionals, and consumers. Growers can use the research to plan production and pricing. Retailers and marketers can use it to understand customer demand and improve promotions. Importers and distributors can use the information to make better inventory and supply-chain decisions.

Customized Figure 1: Price by Avocado Type

ggplot(data, aes(x = type, y = average_price, fill = type)) +
  geom_boxplot() +
  labs(
    title = "Average Price by Avocado Type",
    x = "Avocado Type",
    y = "Average Price"
  ) +
  theme_minimal()

Organic avocados generally had higher prices than conventional avocados. This suggests that some consumers are willing to pay more for organic products.

Customized Figure 2: Sales Volume by Year

ggplot(data, aes(x = factor(year), y = total_volume, fill = type)) +
  geom_col(position = "dodge") +
  labs(
    title = "Avocado Sales Volume by Year and Type",
    x = "Year",
    y = "Total Sales Volume",
    fill = "Type"
  ) +
  theme_minimal()

Conventional avocados had much higher sales volume than organic avocados. This suggests that conventional avocados appeal to a larger customer base.

Question 2: Highest-Selling Cities

data$sales_dollars <- data$total_volume * data$average_price

city_sales <- data %>%
  filter(year %in% c(2017, 2018)) %>%
  group_by(year, type, geography) %>%
  summarise(
    total_sales = sum(sales_dollars),
    .groups = "drop"
  ) %>%
  arrange(year, type, desc(total_sales))

city_sales
## # A tibble: 164 × 4
##     year type         geography            total_sales
##    <int> <chr>        <chr>                      <dbl>
##  1  2017 conventional Los Angeles            13456647.
##  2  2017 conventional New York                9322034.
##  3  2017 conventional Chicago                 5161767.
##  4  2017 conventional Houston                 5125212.
##  5  2017 conventional San Francisco           5080416.
##  6  2017 conventional Dallas/Ft. Worth        4940102.
##  7  2017 conventional Baltimore/Washington    4767953.
##  8  2017 conventional Denver                  4212002.
##  9  2017 conventional Phoenix/Tucson          3817358.
## 10  2017 conventional Miami/Ft. Lauderdale    3732871.
## # ℹ 154 more rows

Using dollar sales, New York had the highest organic avocado sales in both 2017 and 2018. Los Angeles had the highest conventional avocado sales in both years.

New York may have high organic avocado sales because of its large population and strong demand for healthy foods. Los Angeles may have high conventional sales because of its large population, many grocery stores, health-conscious consumers, and proximity to California avocado production.

Question 3: Business Insights

The customized figures provide several business insights. Organic avocados generally had higher prices, which may create higher profit margins. Conventional avocados had much higher sales volume, showing that they appeal to a larger customer base. Businesses could continue offering conventional avocados while expanding organic products in cities where organic demand is strongest.

Conclusion

The analysis showed that avocado prices vary by type and that conventional avocados sell in much larger quantities than organic avocados. New York had the highest organic dollar sales, while Los Angeles had the highest conventional dollar sales. Businesses can use this information to make better pricing, inventory, and promotional decisions.