1変数の分布

Rで学ぶ探索的データ分析

Andrew Bray

Assistant Professor, Reed College

周辺分布 vs 条件付き分布

ggplot(cars, aes(x = hwy_mpg)) +
  geom_histogram()
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Warning message:
Removed 14 rows containing non-finite values (stat_bin). 

ch2_2.003.png

Rで学ぶ探索的データ分析

周辺分布 vs 条件付き分布

ggplot(cars, aes(x = hwy_mpg)) +
  geom_histogram() +
  facet_wrap(~pickup)
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Warning message:
Removed 14 rows containing non-finite values (stat_bin).

ch2_2.006.png

Rで学ぶ探索的データ分析

データパイプラインの構築

cars2 <- cars %>%
  filter(eng_size < 2.0)

ggplot(cars2, aes(x = hwy_mpg)) +
  geom_histogram()
Rで学ぶ探索的データ分析

データパイプラインの構築

cars %>%
  filter(eng_size < 2.0) %>%
  ggplot(aes(x = hwy_mpg)) +
  geom_histogram()
Rで学ぶ探索的データ分析

フィルターとファセットのヒストグラム

cars %>%
  filter(eng_size < 2.0) %>%
  ggplot(aes(x = hwy_mpg)) +
  geom_histogram()
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

ch2_2.011.png

Rで学ぶ探索的データ分析

ビン幅が広い

cars %>%
  filter(eng_size < 2.0) %>%
  ggplot(aes(x = hwy_mpg)) +
  geom_histogram(binwidth = 5)

ch2_2.013.png

Rで学ぶ探索的データ分析

密度プロット

cars %>%
  filter(eng_size < 2.0) %>%
  ggplot(aes(x = hwy_mpg)) +
  geom_density()

ch2_2.015.png

Rで学ぶ探索的データ分析

帯域幅が広い

cars %>%   
  filter(eng_size < 2.0) %>%
  ggplot(aes(x = hwy_mpg)) +
  geom_density(bw = 5)

ch2_2.017.png

Rで学ぶ探索的データ分析

¡Vamos a practicar!

Rで学ぶ探索的データ分析

Preparing Video For Download...