dplyr is a package for the R language that provides a grammar of data manipulation, a small set of consistent verbs for filtering, selecting, changing and summarising data frames. It makes cleaning and summarising data readable, and it can work with remote database tables as well as local datasets.
This page is for data leaders and analysts who want a clear definition. It covers the core verbs, database use, how dplyr compares with SQL and pandas, and how it relates to AI agents.
The dplyr website describes dplyr as a grammar of data manipulation, and as a fast, consistent tool for working with data frame like objects. It is part of the tidyverse, a collection of R packages for data science. Instead of writing loops, you describe each change to a table with a short verb.
The website lists five main verbs. The dplyr introduction adds that all dplyr functions take a data frame as the first argument, later arguments describe the operation, and the result is a new data frame. Together these properties make it easy to chain simple steps into a complex result.
| Verb | What it does | Typical question |
|---|---|---|
| filter() | Picks rows based on their values | Which orders are above a threshold? |
| select() | Picks columns based on their names | Which fields do I need? |
| mutate() | Adds new variables that are functions of existing ones | What is the margin per order? |
| arrange() | Changes the order of the rows | Which records come first? |
| summarise() | Reduces many values to a single summary | What is the average per region? |
The group_by() verb combines with these so that any operation can be performed by group. For example, grouping by two columns and then summarising gives one row of results per combination. The introduction also shows the pipe operator, which passes each result into the next step so the code reads left to right.
The dbplyr documentation explains that dbplyr lets you work with remote database tables as if they were local data frames, by automatically converting dplyr code into SQL. Calls are evaluated lazily: SQL is only sent to the database when you request the data, for example with collect(). Basic features work with any database that has a DBI back end.
This matters for governance. The query runs where the data lives, so large tables need not be copied into a laptop session, and the generated SQL can be inspected and reviewed.
| Tool | Style | Where it runs | Best fit |
|---|---|---|---|
| dplyr | Chained verbs in R | In memory, or translated to SQL through dbplyr | Analysts working in R and the tidyverse |
| SQL | Declarative queries | Inside the database | Shared, set-based logic close to the data |
| pandas | Method chaining in Python | In memory | Analysts working in Python |
They solve the same problem in different languages. Choose by the skills of your team and by where the data sits, not by which tool is fashionable. For the wider picture of how analysts move from raw tables to reporting, see our entry on business analytics.
Agents that answer data questions often write or run transformation code. Verb-based code such as dplyr is easy to read and review, which helps when a person must check what an agent did. The harder problem is the context around the code: which table is the source of truth, who may see which columns, and which policy applied. ElixirData is XenonStack's Context OS, a decision infrastructure platform for exactly that layer.
show_query() before running costly queries.To map one decision your agents make from analysed data, and the data and policy it depends on, book a Context Workshop. See what happens in the workshop.
dplyr is used to filter rows, select columns, create new variables, sort and summarise data frames in R, using a small set of consistent verbs.
Yes. dplyr is a core tidyverse package, and the easiest way to install it is to install the whole tidyverse, although it can also be installed on its own.
Yes. With dbplyr, dplyr code is converted into SQL and sent to the database only when you request the data.
It lets you perform any operation by group, so that functions such as summarise() return one result per group.
No. Both transform tabular data, but dplyr is a set of R verbs, while SQL is a query language that runs inside the database. dbplyr translates between them.