LoslegenKostenlos loslegen

Unnesting a data frame

You now have a tidied version of each model stored in the tidied column. You want to combine all of those into a large data frame, similar to how you combined the US and UK tidied models earlier. Recall that the unnest() function from tidyr achieves this.

Diese Übung ist Teil des Kurses

Case Study: Exploratory Data Analysis in R

Kurs anzeigen

Anleitung zur Übung

  • Add an unnest() step to unnest the tidied models stored in the tidied column. Save the result as country_coefficients.
  • Print the resulting country_coefficients object to the console.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Add one more step that unnests the tidied column
___ <- by_year_country %>%
  nest(-country) %>%
  mutate(model = map(data, ~ lm(percent_yes ~ year, data = .)),
         tidied = map(model, tidy))


# Print the resulting country_coefficients variable
Code bearbeiten und ausführen