# 変数の消去
rm(list = ls())
# パッケージ `pacman`を使って必要なパッケージをインストール
if(!require("pacman")) install.packages("pacman")
##  要求されたパッケージ pacman をロード中です
pacman::p_load("tidyverse",   #  基本のパッケージ
               "skimr",     #  記述統計のパッケージ
               "gt")      #  表(table)をデータフレームから作るパッケージ

# 表示を科学表示から変更
 options(scipen = 999)
dat_temp <- read_csv("数理/QFR2023TermPaper (3).csv")
## New names:
## Rows: 350 Columns: 5
## ── Column specification
## ────────────────────────────────────────────────────────
## Delimiter: "," chr (1): Fish_Market dbl (4): ...1, Year, Month, Total
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
skimr::skim(dat_temp)
Data summary
Name dat_temp
Number of rows 350
Number of columns 5
_______________________
Column type frequency:
character 1
numeric 4
________________________
Group variables None

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
Fish_Market 0 1 8 8 0 2 0

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
…1 0 1 175.50 101.18 1 88.25 175.5 262.75 350 ▇▇▇▇▇
Year 0 1 2005.13 6.92 1994 1999.00 2005.0 2011.00 2019 ▇▇▇▆▃
Month 0 1 8.33 2.91 1 7.00 9.0 11.00 12 ▂▁▅▆▇
Total 0 1 2317.37 3038.65 0 1.00 640.0 4176.50 13095 ▇▂▂▁▁
summary_1 <- dat_temp |> group_by(Year, Month) |> summarize(Total)
## Warning: Returning more (or less) than 1 row per `summarise()` group was deprecated in
## dplyr 1.1.0.
## ℹ Please use `reframe()` instead.
## ℹ When switching from `summarise()` to `reframe()`, remember that `reframe()`
##   always returns an ungrouped data frame and adjust accordingly.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## `summarise()` has grouped output by 'Year', 'Month'. You can override using the
## `.groups` argument.
summary_1 <- dat_temp |> group_by(Year,Month)|>
  
  mutate(Month=as.integer(Month),Year=as.integer(Year))|>
ungroup()
fig_1 <-  ggplot(summary_1, aes(x = Month, y = Total, fill = Year)) + 
            geom_bar(stat = "identity", position = "dodge")+scale_x_continuous(breaks = seq(1,12,1))

fig_1