dplyr
27 steps in 8 sets of R.
The tour at the center of modern R. Tibbles and column selection, filtering rows, mutate, group_by, window functions, and all six joins plus join_by for keys that do not share a name.
Twenty-seven steps, the longest R tour here, because dplyr is what most R code now looks like. The pipe does a lot of the work and the verbs are deliberately few, which is the whole design.
Tibbles & columns
- TibblesA tibble prints tidily, never converts strings, and never partial-matches.
- selectChoosing columns by name, position, pattern or type.
- Reordering columnsrelocate moves columns without listing every other one.
- The pipeChaining operations left to right instead of nesting.
Rows
- filterKeeping rows, with conditions combined by comma or by operator.
- arrangeSorting rows, ascending by default and descending on request.
- Distinct and duplicatesDropping repeated rows, and finding the ones that repeat.
- Picking rows per groupThe top row per group, and the other slice variants.
- filter and selectdplyr's verbs for choosing rows and columns.
New columns
- mutateAdding or replacing columns, computed from the ones already there.
- case_when and if_elseVectorized conditionals, evaluated in order.
- acrossApplying the same transformation to several columns at once.
- mutate and case_whenAdding and deriving columns inside a pipeline.
Grouping
- group_byGrouping persists until you ungroup, which is the usual source of bugs.
- summarizeCollapsing many rows into one, or one per group.
- Counting and proportionsCounts, shares within groups, and the tidy way to a percentage table.
- group_by and summarizeThe split-apply-combine heart of dplyr.
Windows & rows
- Window functionslag, lead, cumulative functions and ranking, within a group.
- Row-wise workrowwise turns each row into its own group, for calculations across columns.
- Per-group functionsgroup_modify hands each group to a function as a data frame.
Joining
- JoinsThe six joins, and what each one does to unmatched rows.
- Joining on different keysjoin_by handles renamed keys, inequality joins and rolling matches.
- Combining tablesbind_rows stacks, bind_cols widens, and both check what they can.
- dplyr joinsCombining tibbles with explicit join verbs.
Ending a pipeline
- Pulling values outpull takes one column as a vector, which ends a pipeline.
- Looking at a tableglimpse, skim-style summaries, and counting missing values per column.
Encore
- tidy_pipeline.RA full tidyverse pipeline: wrangle, summarize, and plot.