Aan de slagGa gratis aan de slag

Visualizing the Adjusted Demographic Trends

Let's compare changes in borrowing across demographics over time. The data frame rydf you created in the last exercise is available in your workspace.

Note: We removed the row corresponding to "Not Avail".

Deze oefening maakt deel uit van de cursus

Scalable Data Processing in R

Cursus bekijken

Oefeninstructies

tidyr and ggplot2 are loaded in your workspace.

  • Print the rydf and pop_proportion objects.
  • Convert rydf to a long-formatted data frame by gathering all columns except Race.
  • Create a line chart with Year and Adjusted_Count on the x and y axes, respectively.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# View rydf
___ 

# View pop_proportion
___

# Gather on all variables except Race
rydfl <- ___(rydf, ___, names_to = "Year", values_to = "Count")

# Create a new adjusted count variable
rydfl$Adjusted_Count <- rydfl$Count / pop_proportion[rydfl$Race]

# Plot
ggplot(rydfl, aes(x = ___, y = ___, group = Race, color = Race)) + 
    geom_line()
Code bewerken en uitvoeren