Module lessons (1/2)
Filter, Select and Sort with dplyr
Concatenate select(), filter(), and arrange(desc()) with the pipe operator %>% to extract and sort records.
What you'll learn in this lesson
- Read and write sequential pipelines with the pipe operator
%>%(and the native pipe|>introduced in R 4.1). - Select and exclude columns declaratively with
select(). - Filter lines with readable predicates via
filter()(without having to repeatdf$or worry aboutNA). - Sort records ascending or descending with
arrange()anddesc().
Overview
In Base R, combining filtering, column choosing, and sorting often results in reverse-nested parentheses (arrange(select(filter(df, ...)))) that are difficult to read. The dplyr package (heart of the Tidyverse) solves the problem with clear verbs and the pipe (%>%) operator.
The pipe takes the result of the expression on the left and automatically passes it as the first argument of the function on the right:
Sections covered in this lesson
- 1How the Pipe works (
%>%and|>) - 2Test yourself: guided exercises
- 3Concept check
Unlock "Filter, Select and Sort with dplyr" and the full Course R curriculum
Concatenate select(), filter(), and arrange(desc()) with the pipe operator %>% to extract and sort records.
Unlock all 7 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in Course R plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.