MulaiMulai sekarang secara gratis

Using summarize, slice_max, and count together

In this chapter, you've learned to use six dplyr verbs related to aggregation: count(), group_by(), summarize(), ungroup(), slice_max(), and slice_min(). In this exercise, you'll combine them to answer a question:

In how many states do more people live in metro areas than non-metro areas?

Recall that the metro column has one of the two values "Metro" (for high-density city areas) or "Nonmetro" (for suburban and country areas).

counties_selected <- counties %>%
  select(state, metro, population)

Latihan ini adalah bagian dari kursus

Data Manipulation with dplyr

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

counties_selected %>%
  # Find the total population for each combination of state and metro
  ___
  
Edit dan Jalankan Kode