LoslegenKostenlos loslegen

Sorting by slope

Now that you've filtered for countries where the trend is probably not due to chance, you may be interested in countries whose percentage of "yes" votes is changing most quickly over time. Thus, you want to find the countries with the highest and lowest slopes; that is, the estimate column.

Diese Übung ist Teil des Kurses

Case Study: Exploratory Data Analysis in R

Kurs anzeigen

Anleitung zur Übung

  • Using arrange() and desc(), sort the filtered countries to find the countries whose percentage "yes" is most quickly increasing over time.
  • Using arrange(), sort to find the countries whose percentage "yes" is most quickly decreasing.

Interaktive Übung

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

# Filter by adjusted p-values
filtered_countries <- country_coefficients %>%
  filter(term == "year") %>%
  mutate(p.adjusted = p.adjust(p.value)) %>%
  filter(p.adjusted < .05)

# Sort for the countries increasing most quickly



# Sort for the countries decreasing most quickly

Code bearbeiten und ausführen