BaşlayınÜcretsiz başlayın

Transformations

Highly skewed distributions can make it very difficult to learn anything from a visualization. Transformations can be helpful in revealing the more subtle structure.

Here you'll focus on the population variable, which exhibits strong right skew, and transform it with the natural logarithm function (log() in R).

Bu egzersiz, kursun bir parçasıdır

Exploratory Data Analysis in R

Kursa Göz Atın

Egzersiz talimatları

Using the gap2007 data:

  • Create a density plot of the population variable.
  • Mutate a new column called log_pop that is the natural log of the population and save it back into gap2007.
  • Create a density plot of your transformed variable.

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

# Create density plot of old variable
gap2007 %>%
  ggplot(aes(x = ___)) +
  ___

# Transform the skewed pop variable
gap2007 <- gap2007 %>%
  mutate(___)

# Create density plot of new variable
gap2007 %>%
  ggplot(aes(x = ___)) +
  ___
Kodu Düzenle ve Çalıştır