Daily Fish Price Analysis 2021

library(tidyverse)
library(readr)
fish_market <- read.csv("C:/Users/bmire/Desktop/MEF BDA/R Course/balik_hal_fiyatlari.csv",stringsAsFactors = FALSE, header = TRUE,sep = ";", encoding="UTF-8")

In this document, the daily fish price analyzed by using tidyverse package for 2021. We get the data from İzmir Metropolitan Municipality Open Data Portal.

head(fish_market)
##                 TARIH MAL_TURU           MAL_ADI BIRIM ASGARI_UCRET AZAMI_UCRET
## 1 2021-01-02 00:00:00    BALIK     TIRSI (DENİZ)    KG         5.83        12.5
## 2 2021-01-02 00:00:00    BALIK KIRLANGIÇ (DENİZ)    KG         3.00        80.0
## 3 2021-01-02 00:00:00    BALIK    ÇİMÇİM (DENİZ)    KG         3.50         8.0
## 4 2021-01-02 00:00:00    BALIK   HANOS ( DENİZ )    KG         2.50         5.0
## 5 2021-01-02 00:00:00    BALIK     KILIÇ (DENİZ)    KG        45.00        45.0
## 6 2021-01-02 00:00:00    BALIK    LÜFER ( DENİZ)    KG       130.00       130.0

According to MAL_TURU, it displayed average minimum and maximum fish prices.The average BALIK price is the more expensive for both the prices than others. Also, the KÜLTÜR difference of prices is more over than others.

fm_mal_turu <- fish_market %>%  
               group_by(MAL_TURU) %>% 
               summarize(OrtAsgariUcret = mean(ASGARI_UCRET), OrtAzamiUcret = mean(AZAMI_UCRET))
fm_mal_turu
## # A tibble: 4 x 3
##   MAL_TURU      OrtAsgariUcret OrtAzamiUcret
##   <chr>                  <dbl>         <dbl>
## 1 BALIK                   30.9          68.4
## 2 İTHAL (DONUK)           24.6          30.9
## 3 KÜLTÜR                  22.2          64.5
## 4 TATLI SU                29.6          35.7
plot_1 <- ggplot(fm_mal_turu, aes(x = MAL_TURU , y = OrtAsgariUcret)) + geom_col() + expand_limits(y = 0)
plot_2 <- ggplot(fm_mal_turu, aes(x = MAL_TURU , y = OrtAzamiUcret)) + geom_col() + expand_limits(y = 0)
plot_1

plot_2

Here, we can see the seasonal price change.At the beginning of the season, the prices start low and increase towards the end of the season. The prices of imported frozen fish species increase excessively at the end of the season, and the prices decrease as they approach the beginning of the season. We can clearly see the change in prices according to the supply-demand balance.

fm_trend <- fish_market %>% select(TARIH, MAL_TURU, MAL_ADI, BIRIM, ASGARI_UCRET, AZAMI_UCRET) %>% 
            group_by(AY = lubridate::month(TARIH,label=TRUE, abbr = TRUE), MAL_TURU) %>% 
            summarize(OrtAsgariUcret = mean(ASGARI_UCRET), OrtAzamiUcret = mean(AZAMI_UCRET))
fm_trend
## # A tibble: 40 x 4
## # Groups:   AY [10]
##    AY    MAL_TURU      OrtAsgariUcret OrtAzamiUcret
##    <ord> <chr>                  <dbl>         <dbl>
##  1 Oca   BALIK                   23.9          52.2
##  2 Oca   İTHAL (DONUK)           11.7          17.2
##  3 Oca   KÜLTÜR                  18.3          61.3
##  4 Oca   TATLI SU                24.3          29.8
##  5 Şub   BALIK                   25.5          56.6
##  6 Şub   İTHAL (DONUK)           16.0          22.9
##  7 Şub   KÜLTÜR                  17.6          65.3
##  8 Şub   TATLI SU                26.5          30.8
##  9 Mar   BALIK                   26.6          63.4
## 10 Mar   İTHAL (DONUK)           19.1          24.1
## # ... with 30 more rows
plot_3 <- ggplot(fm_trend, aes(x = AY , y = OrtAzamiUcret, color = MAL_TURU, group = MAL_TURU)) + geom_line(size=1) + expand_limits(y = 0) 
plot_4 <- ggplot(fm_trend, aes(x = AY , y = OrtAsgariUcret, color = MAL_TURU, group = MAL_TURU)) + geom_line(size=1) + expand_limits(y = 0)
plot_3

plot_4

In this analysis, we see the top 3 product names sorted according to the average maximum price for each month. Istakoz(Deniz) is the most expensive seafood in every month.

ma_max3 <- fish_market %>% select(TARIH, MAL_TURU, MAL_ADI, BIRIM, ASGARI_UCRET, AZAMI_UCRET) %>% 
            group_by(AY = lubridate::month(TARIH,label=TRUE, abbr = TRUE),MAL_ADI) %>% 
            summarize(OrtAsgariUcret = mean(ASGARI_UCRET), OrtAzamiUcret = mean(AZAMI_UCRET)) %>% 
            slice_max(order_by = OrtAzamiUcret, n = 3)
ma_max3
## # A tibble: 30 x 4
## # Groups:   AY [10]
##    AY    MAL_ADI         OrtAsgariUcret OrtAzamiUcret
##    <ord> <chr>                    <dbl>         <dbl>
##  1 Oca   İSTAKOZ (DENİZ)          202.           232.
##  2 Oca   SİNARİT (DENİZ)          100.           167.
##  3 Oca   KARİDES (DENİZ)           77.3          160.
##  4 Şub   İSTAKOZ (DENİZ)          172.           288.
##  5 Şub   KALKAN (DENİZ)           120.           173.
##  6 Şub   KARİDES (DENİZ)           68.4          173.
##  7 Mar   İSTAKOZ (DENİZ)          140.           324.
##  8 Mar   KARİDES (DENİZ)           64.2          246.
##  9 Mar   KALKAN (DENİZ)           134.           186.
## 10 Nis   İSTAKOZ (DENİZ)          197.           335.
## # ... with 20 more rows
max_plot <- ggplot(ma_max3, aes(x = AY, y = OrtAzamiUcret, fill = MAL_ADI)) + geom_bar(stat = "identity", position = position_dodge(), alpha = 0.75)

max_plot

We see 3 seafood that has the most differences between the average maximum and minimum prices.

diff_df = fish_market %>% select(TARIH, MAL_TURU, MAL_ADI, BIRIM, ASGARI_UCRET, AZAMI_UCRET) %>% 
          group_by(AY = lubridate::month(TARIH,label=TRUE, abbr = TRUE),MAL_ADI) %>% 
          summarize(Fark = mean(AZAMI_UCRET)-mean(ASGARI_UCRET)) %>% 
          slice_max(order_by = Fark, n = 3)
diff_df
## # A tibble: 30 x 3
## # Groups:   AY [10]
##    AY    MAL_ADI            Fark
##    <ord> <chr>             <dbl>
##  1 Oca   MERCAN (BÜYÜKBOY)  149.
##  2 Oca   DIL                125.
##  3 Oca   BARBUN (TEKİR)     115 
##  4 Şub   MERCAN (BÜYÜKBOY)  148.
##  5 Şub   BARBUN (TEKİR)     129.
##  6 Şub   DIL                125.
##  7 Mar   İSTAKOZ (DENİZ)    184.
##  8 Mar   KARİDES (DENİZ)    182.
##  9 Mar   BARBUN (TEKİR)     164.
## 10 Nis   İSTAKOZ (DENİZ)    139.
## # ... with 20 more rows
diff_plot <- ggplot(diff_df, aes(x = AY, y = Fark, fill = MAL_ADI)) + geom_bar(stat = "identity", position = position_dodge(), alpha = 0.75)

diff_plot