dplyr (tidyverse) provides verbs—filter, select, mutate, summarise, arrange—for readable data manipulation. Install locally: install.packages("dplyr"). The playground uses base R equivalents.
dplyr idioms (local)
library(dplyr)
df |> filter(score >= 90) |> arrange(desc(score))
The pipe (|> base or %>% magrittr) chains steps left-to-right—similar spirit to method chains in pandas.
Base R equivalent (playground)
df_sub <- df[df$score >= 90, ]
df_sub <- df_sub[order(-df_sub$score), ]
Same logic without dplyr—useful when packages are unavailable.
Important interview questions and answers
- Q: What does filter() do?
A: Keeps rows matching conditions—like SQL WHERE or df[mask, ]. - Q: Why dplyr locally?
A: Readable pipelines for analytics teams; playground teaches concepts with base R.
Self-check
- What base R syntax filters rows by score >= 90?
- Name one dplyr verb for creating new columns.
Tip: Install dplyr locally—playground filters with df[df$score >= 90, ] instead.
Interview prep
- filter in base R?
df[df$score >= 90, ]keeps matching rows.