Rで何かをしたり、読書をするブログ

政府統計の総合窓口のデータや、OECDやUCIやのデータを使って、Rの練習をしています。ときどき、読書記録も載せています。

都道府県別の定期健康診断結果報告のデータの分析2 - R で箱ひげ図と散布図を描く

www.crosshyou.info

の続きです。前回はCSVファイルのデータを R に読み込ませました。今回はグラフを描いて、データの様子がどんなものかを把握します。調査年度によってデータが変わっているかどうかをみたいです。

place: 検診実施事業場数 と year を箱ひげ図にしてみてみます。

調査年の違いはなさそうですね。place を対数変換して同じように箱ひげ図を描きます。

対数変換しても外れ値が一つありますね。たぶん東京都でしょう。

次は、jushin: 受診者数【人】 と year です。

これも同じような感じです。対数変換した jushin でも箱ひげ図をつくります。

調査年度による違いは無さそうです。

次は、shoken: 所見のあった者_人数【人】 と year です。

shoken も対数変換します。

これもいままでの箱ひげ図と同じような形状です。

shokenritsu: 所見のあった者_有所見率【%】と year の箱ひげ図を描きます。

わずかですが、year が新しくなるにつれて、shokenritu が上昇しているように見えます。

次は、per_jushin: 1事業場当たりの受診者数 と year です。

こちらは年々、減っている感じです。

shokenritu と per_jushin の散布図を描いてみます。

なんとくですが、負の相関関係があるように見えます。

1事業所当たりの受診者数が多いと所見率が低いということですかね。

今回は以上です。

次回は、

www.crosshyou.info

です。

 

はじめから読むには、

www.crosshyou.info

です。

今回のコードは以下になります。

#
# place: 検診実施事業場数 とyear
df |> 
  ggplot(aes(y = place, group = year)) +
  geom_boxplot(aes(x = year, fill = year)) +
  theme_minimal()
#
# log(place)とyear
df <- df |>
  mutate(log_place = log(place))
#
df |> 
  ggplot(aes(y = log_place, group = year)) +
  geom_boxplot(aes(x = year, fill = year)) +
  theme_minimal()
#
# jushin: 受診者数【人】と year
df |> 
  ggplot(aes(x = year, y = jushin, group = year)) +
  geom_boxplot(aes(fill = year)) +
  theme_minimal()
#
# log(jushin)とyear
df <- df |> 
  mutate(log_jushin = log(jushin))
#
df |> 
  ggplot(aes(x = year, y = log_jushin, group = year)) +
  geom_boxplot(aes(fill = year)) +
  theme_minimal()
#
# shoken: 所見のあった者_人数【人】とyear
df |> 
  ggplot(aes(x = year, y = shoken, group = year)) +
  geom_boxplot(aes(fill = year)) +
  theme_minimal()
#
# log(shoken)とyear
df <- df |> 
  mutate(log_shoken = log(shoken))
#
df |> 
  ggplot(aes(x = year, y = log_shoken, group = year)) +
  geom_boxplot(aes(fill = year)) +
  theme_minimal()
#
# shokenritsu: 所見のあった者_有所見率【%】とyear
df |> 
  ggplot(aes(x = year, y = shokenritsu, group = year)) +
  geom_boxplot(aes(fill = year)) +
  theme_minimal()
#
# per_jushin: 1事業場当たりの受診者数 と year
df |> 
  ggplot(aes(x = year, y = per_jushin, group = year)) +
  geom_boxplot(aes(fill = year)) +
  theme_minimal()
#
# shokenritsuとper_jushin
df |> 
  ggplot(aes(x = per_jushin, y = shokenritsu)) +
  geom_point(aes(color = year), size = 3) +
  theme_minimal()
#

(冒頭の画像は、Bing Image Creator で生成しました。プロンプトは、Landscape of natural east Asian countries, close up of white baby's breath flowers, photo です。)