การกระจายของตัวแปรหนึ่งตัว

การวิเคราะห์เชิงสำรวจข้อมูลใน R

Andrew Bray

Assistant Professor, Reed College

Marginal vs. conditional

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

Marginal vs. conditional

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

การสร้าง data pipeline

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

ggplot(cars2, aes(x = hwy_mpg)) +
  geom_histogram()
การวิเคราะห์เชิงสำรวจข้อมูลใน R

การสร้าง data pipeline

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

มาฝึกกันเถอะ!

การวิเคราะห์เชิงสำรวจข้อมูลใน R

Preparing Video For Download...