Exercise

Transforming variables

When variables have skewed distributions, they often require a transformation in order to form a linear relationship with another variable so that correlation can be computed. In this exercise, you'll perform a transformation yourself.

Both dplyr and ggplot2 are loaded and world_happiness is available.

Instructions 1/2

undefined XP
  • 1
    • Create a scatterplot of happiness_score versus gdp_per_cap.
    • Calculate the correlation between happiness_score and gdp_per_cap.
  • 2
    • Add a new column to world_happiness called log_gdp_per_cap that contains the log of gdp_per_cap.
    • Create a scatterplot of happiness_score versus log_gdp_per_cap.
    • Calculate the correlation between happiness_score and log_gdp_per_cap.