# 変数の消去
rm(list = ls())

# パッケージ `pacman`を使って必要なパッケージをインストール
if(!require("pacman")) install.packages("pacman")
##  要求されたパッケージ pacman をロード中です
pacman::p_load("tidyverse", 
               "skimr", "gt")

# 表示を科学表示から変更
 options(scipen = 999)
library(skimr) # 表を作るパッケージ
market_data_raw <- 
      readr::read_csv("C:/Users/01102/OneDrive/デスクトップ/データ3/tairyo_navi_Flounder_teaching2023.csv")
## Rows: 1937 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (4): Market, Gear_Type, Species, Standard
## dbl  (5): Landing_Amount, Landing_Price, Highest_Price, Average_Price, Lowes...
## date (1): Landing_Date
## 
## ℹ 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.
market_data_raw |> skimr::skim() 
Data summary
Name market_data_raw
Number of rows 1937
Number of columns 10
_______________________
Column type frequency:
character 4
Date 1
numeric 5
________________________
Group variables None

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
Market 0 1 2 3 0 14 0
Gear_Type 0 1 2 6 0 11 0
Species 0 1 3 3 0 1 0
Standard 0 1 1 2 0 4 0

Variable type: Date

skim_variable n_missing complete_rate min max median n_unique
Landing_Date 0 1 1994-06-20 2021-09-03 2007-10-06 1675

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
Landing_Amount 0 1 17.62 44.69 -7 1.8 5.50 17.00 836.30 ▇▁▁▁▁
Landing_Price 0 1 19936.37 55647.62 -11188 1971.0 6491.00 21850.00 1842700.00 ▇▁▁▁▁
Highest_Price 0 1 1758.92 1316.78 0 860.0 1500.00 2420.00 10000.00 ▇▃▁▁▁
Average_Price 0 1 1341.93 1348.62 0 700.0 1092.81 1696.03 43873.81 ▇▁▁▁▁
Lowest_Price 0 1 801.69 845.92 0 300.0 600.00 1000.00 8500.00 ▇▁▁▁▁
market_data_raw |> distinct(Gear_Type)
## # A tibble: 11 × 1
##    Gear_Type   
##    <chr>       
##  1 底刺網      
##  2 小延縄      
##  3 定置網      
##  4 底びき網    
##  5 その他      
##  6 磯建網      
##  7 底延縄      
##  8 小延縄(新)
##  9 かご        
## 10 搬入        
## 11 一本釣り
market_data_raw |> ggplot(aes(x = Gear_Type)) + geom_bar() +   theme(text = element_text(family = "HiraKakuPro-W3")) 
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): Windows
## のフォントデータベースにフォントファミリが見付かりません

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): Windows
## のフォントデータベースにフォントファミリが見付かりません
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows のフォントデータベースにフォントファミリが見付かりません

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows のフォントデータベースにフォントファミリが見付かりません

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows のフォントデータベースにフォントファミリが見付かりません

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows のフォントデータベースにフォントファミリが見付かりません

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows のフォントデータベースにフォントファミリが見付かりません

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows のフォントデータベースにフォントファミリが見付かりません
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows のフォントデータベースにフォントファミリが見付かりません

market_data_raw |> group_by(Gear_Type) |> summarize(n =n())
## # A tibble: 11 × 2
##    Gear_Type        n
##    <chr>        <int>
##  1 かご           107
##  2 その他         152
##  3 一本釣り        18
##  4 定置網         814
##  5 小延縄         100
##  6 小延縄(新)    13
##  7 底びき網        41
##  8 底刺網         516
##  9 底延縄          17
## 10 搬入            29
## 11 磯建網         130
market_data_raw |> distinct(Standard)
## # A tibble: 4 × 1
##   Standard
##   <chr>   
## 1 活魚    
## 2 山      
## 3 生鮮    
## 4 不明
market_data_raw |> ggplot(aes(x = Standard)) + geom_bar() +   theme(text = element_text(family = "HiraKakuPro-W3")) 
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows のフォントデータベースにフォントファミリが見付かりません

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows のフォントデータベースにフォントファミリが見付かりません

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows のフォントデータベースにフォントファミリが見付かりません

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows のフォントデータベースにフォントファミリが見付かりません

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows のフォントデータベースにフォントファミリが見付かりません

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows のフォントデータベースにフォントファミリが見付かりません

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows のフォントデータベースにフォントファミリが見付かりません
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## Windows のフォントデータベースにフォントファミリが見付かりません

market_data_raw |> group_by(Standard) |> summarize(n =n())
## # A tibble: 4 × 2
##   Standard     n
##   <chr>    <int>
## 1 不明       302
## 2 山         173
## 3 活魚       719
## 4 生鮮       743