A0521002 折笠空生
Rのデータをもとに木のデータの特徴を捉える。
# 変数の消去
rm(list = ls())
# 表示を科学表示から変更
options(scipen = 999)
# パッケージ `pacman`を使って必要なパッケージをインストール
if(!require("pacman")) install.packages("pacman")
## 要求されたパッケージ pacman をロード中です
pacman::p_load("tidyverse", "skimr")
# データサイエンスのための基本パッケージセット
# https://www.tidyverse.org/
library(tidyverse)
# readr, readxl, googlesheet 4は tidyverseに含まれる
# 読み込んだデータのまとめ
library(skimr)
library(gt)
getwd()
## [1] "C:/Users/coo/Documents"
trees_temp<-trees
str(trees_temp)
## 'data.frame': 31 obs. of 3 variables:
## $ Girth : num 8.3 8.6 8.8 10.5 10.7 10.8 11 11 11.1 11.2 ...
## $ Height: num 70 65 63 72 81 83 66 75 80 75 ...
## $ Volume: num 10.3 10.3 10.2 16.4 18.8 19.7 15.6 18.2 22.6 19.9 ...
skimr::skim(trees_temp)
Data summary
| Name |
trees_temp |
| Number of rows |
31 |
| Number of columns |
3 |
| _______________________ |
|
| Column type frequency: |
|
| numeric |
3 |
| ________________________ |
|
| Group variables |
None |
Variable type: numeric
| Girth |
0 |
1 |
13.25 |
3.14 |
8.3 |
11.05 |
12.9 |
15.25 |
20.6 |
▃▇▃▅▁ |
| Height |
0 |
1 |
76.00 |
6.37 |
63.0 |
72.00 |
76.0 |
80.00 |
87.0 |
▃▃▆▇▃ |
| Volume |
0 |
1 |
30.17 |
16.44 |
10.2 |
19.40 |
24.2 |
37.30 |
77.0 |
▇▅▁▂▁ |
trees_temp |> head(n = 10) |> gt() |>
tab_header(
title = "木",
subtitle="rに入っているデータの一つです")|>
cols_label(
Girth="胴回り" ,
Height="高さ" ,
Volume="重さ"
)
| 木 |
| rに入っているデータの一つです |
| 胴回り |
高さ |
重さ |
| 8.3 |
70 |
10.3 |
| 8.6 |
65 |
10.3 |
| 8.8 |
63 |
10.2 |
| 10.5 |
72 |
16.4 |
| 10.7 |
81 |
18.8 |
| 10.8 |
83 |
19.7 |
| 11.0 |
66 |
15.6 |
| 11.0 |
75 |
18.2 |
| 11.1 |
80 |
22.6 |
| 11.2 |
75 |
19.9 |
trees_temp |> ggplot(aes(x = Height, y = Volume)) +
geom_point()

上部の図より木の高さとその重さには正の相関関係があると考えられる。