Verteilung einer Variable

Explorative Datenanalyse in R

Andrew Bray

Assistant Professor, Reed College

Marginal vs. konditional

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

Explorative Datenanalyse in R

Marginal vs. konditional

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

Explorative Datenanalyse in R

Daten-Pipeline aufbauen

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

ggplot(cars2, aes(x = hwy_mpg)) +
  geom_histogram()
Explorative Datenanalyse in R

Daten-Pipeline aufbauen

cars %>%
  filter(eng_size < 2.0) %>%
  ggplot(aes(x = hwy_mpg)) +
  geom_histogram()
Explorative Datenanalyse in R

Gefiltertes und gefacettetes Histogramm

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

Explorative Datenanalyse in R

Breite Klassenbreite

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

ch2_2.013.png

Explorative Datenanalyse in R

Dichteplot

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

ch2_2.015.png

Explorative Datenanalyse in R

Breite Bandbreite

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

ch2_2.017.png

Explorative Datenanalyse in R

Lass uns üben!

Explorative Datenanalyse in R

Preparing Video For Download...