library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
library(lubridate)
## 
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
df_balfit <- read.csv("C:/Users/gamze/Desktop/deu_data/df_balfit.csv")
df_balfit <- df_balfit  |> 
  mutate(year = lubridate::year(TARIH), 
         month = lubridate::month(TARIH), 
         day = lubridate::day(TARIH))
df_MALADI <- df_balfit |> 
  group_by(MAL_ADI, year) |> 
  summarize(P = mean(ORTALAMA_UCRET))
## `summarise()` has grouped output by 'MAL_ADI'. You can override using the
## `.groups` argument.
df_MALADI
## # A tibble: 615 × 3
## # Groups:   MAL_ADI [139]
##    MAL_ADI          year     P
##    <chr>           <dbl> <dbl>
##  1 AHTAPOT(DONUK)   2020  46.7
##  2 AHTAPOT(DONUK)   2021  60  
##  3 AHTAPOT(DONUK)   2022 160  
##  4 AHTAPOT(DONUK)   2023 110  
##  5 AHTOPOT (DENİZ)  2020  37.0
##  6 AHTOPOT (DENİZ)  2021  66.0
##  7 AHTOPOT (DENİZ)  2022 196. 
##  8 AHTOPOT (DENİZ)  2023 204. 
##  9 AHTOPOT (DENİZ)  2024 228. 
## 10 AKYA (DENİZ)     2020  35.9
## # ℹ 605 more rows
ggplot(df_MALADI, 
       aes(x = year, y = P, group_by=MAL_ADI)) +
  geom_line(color = "purple") +
  labs(title = "Ortalama BALIK FİYATLARI",
       x = "YIL",
       y = "FIYAT") +
  theme_bw()

DONUK_SARDALYA <- df_balfit  |> 
  group_by(MAL_ADI, year)  |> 
  filter(MAL_ADI == "DONUK SARDALYA")  |> 
  summarize(P = mean(ORTALAMA_UCRET))
## `summarise()` has grouped output by 'MAL_ADI'. You can override using the
## `.groups` argument.
ggplot(DONUK_SARDALYA, 
       aes(x = year, y = P)) +
  geom_line(color = "red", size = 2) +
  labs(title = "DONUK SARDALYA",
       x = "YIL",
       y = "FIYAT") +
  theme_bw()

df_MAL_TURU <- df_balfit |>  
  group_by(MAL_TURU, year) |>  
  summarize(P = mean(ORTALAMA_UCRET))
## `summarise()` has grouped output by 'MAL_TURU'. You can override using the
## `.groups` argument.
ggplot(df_MAL_TURU, 
       aes(x = year, y = P, group_by=MAL_TURU, color=MAL_TURU)) +
  geom_line(size = 1) +
  labs(title = "Ortalama Balık Fiyatlari",
       x = "YIL",
       y = "FIYAT") +
  theme_bw()