R Tidyverse: The Essential Verbs

Five dplyr verbs handle 90% of data manipulation tasks. Master these before anything else.

Key Insights

  • filter, select, mutate, summarize, and arrange cover most data tasks
  • The pipe operator |> chains operations into readable data transformations
  • group_by combined with summarize replaces complex aggregate queries

The Five Verbs

library(dplyr)

mtcars |>
  filter(mpg > 20) |>
  select(mpg, cyl, wt) |>
  mutate(kpl = mpg * 0.425) |>
  arrange(desc(kpl)) |>
  summarize(avg_kpl = mean(kpl), .by = cyl)

Grouped Operations

sales |>
  group_by(region, quarter) |>
  summarize(
    total = sum(revenue),
    avg_deal = mean(deal_size),
    n = n()
  )

When to Use Base R Instead

For quick one-off operations or in packages with minimal dependencies, base R is fine. Tidyverse shines in analysis scripts where readability matters.

Liked this? There's more.

Every week: one practical technique, explained simply, with code you can use immediately.