dplyr cur_data() in R: Deprecated; Use pick(everything())
The cur_data() function in dplyr returned the current group's data as a tibble inside summarise() or mutate(). As of dplyr 1.1, it is DEPRECATED; use pick(everything()) instead.
df |> summarise(out = some_fn(cur_data())) # OLD (deprecated) df |> summarise(out = some_fn(pick(everything()))) # NEW cur_data_all() # also deprecated cur_group_id() # different: integer ID cur_group() # different: group values
Need explanation? Read on for examples and pitfalls.
What cur_data() did in one sentence
cur_data() returned the current group's data (excluding grouping columns) as a tibble, inside dplyr verbs on a grouped tibble. Since dplyr 1.1, it is deprecated in favor of pick(everything()) which is more explicit about what's being selected.
Migration
Replace cur_data() with pick(everything()). The new form is functionally equivalent but reads more clearly.
cur_data() and cur_data_all() are BOTH deprecated. The first excluded grouping columns; the second included them. Both replaced by pick(...) with explicit column selection.Five common patterns (legacy)
1. Pass current data to a function
Modern: summarise(out = some_fn(pick(everything()))).
2. Row count
Modern: just use n() (or nrow(pick(everything()))).
3. Pass to model fit
Modern: summarise(model = list(lm(y ~ x, data = pick(everything())))).
4. Filter inside summarise (rare)
Modern: same with pick(everything()).
5. cur_data_all (with grouping cols)
Modern: still pick(everything()) (dplyr 1.1 includes grouping by default in pick).
cur_data() was opaque about which columns were included; pick(everything()) makes it explicit. Code reviewers can see exactly which columns are passed.cur_data() vs pick() vs cur_group()
Three approaches in the deprecation transition.
| Function | Status | Best for |
|---|---|---|
cur_data() |
Deprecated | Migrate to pick |
cur_data_all() |
Deprecated | Migrate to pick |
pick(everything()) |
Recommended | Modern equivalent |
pick(specific, cols) |
Recommended | Explicit column subset |
cur_group() |
Active | Just the group values |
When to use which:
- For new code:
pick(everything())orpick(specific, cols). - Reading old code: cur_data and cur_data_all both mean "current group's data".
- Just need group ID:
cur_group_id().
A practical migration
Search legacy code for cur_data and replace.
For the rare cur_data_all case:
dplyr 1.1's pick(everything()) includes grouping columns by default, matching cur_data_all.
Common pitfalls
Pitfall 1: ignoring the deprecation warning. Code still works but the warning means a future dplyr major version may remove cur_data entirely.
Pitfall 2: confusing cur_data with cur_group_id. They serve different purposes. cur_data was the FULL data; cur_group_id is just an integer.
cur_data and cur_data_all are deprecated as of dplyr 1.1 (Jan 2023). Code using them emits warnings and may break in a future major version. Migrate now.Try it yourself
Try it: Convert a cur_data call to its pick equivalent. Save to ex_pick.
Click to reveal solution
Explanation: pick(everything()) is the direct cur_data replacement. For row counts, n() is even simpler.
Related dplyr functions
After understanding cur_data's deprecation, look at:
pick(): modern column-selection inside verbscur_group_id()/cur_group()/cur_group_rows(): group introspection (still active)n(): row countacross(): per-column transformationc_across(): row-wise across
For most cur_data uses, n() (for counts) or pick() (for full data) covers the use case.
Why cur_data was deprecated
The dplyr team's reasoning: cur_data was implicit, pick is explicit. With cur_data you couldn't tell from the call site which columns were being operated on; with pick(everything()) the intent is visible. Combined with the new tidyselect support in pick (pick(starts_with("x_")) etc.), the new function is strictly more flexible. The deprecation is part of dplyr's broader push toward making pipelines self-documenting.
FAQ
Is cur_data deprecated in dplyr?
Yes, as of dplyr 1.1.0 (Jan 2023). Use pick(everything()) instead.
What is the modern replacement for cur_data?
pick(everything()). It returns the same result but is more explicit about column selection.
What is the difference between cur_data and cur_data_all?
cur_data EXCLUDED grouping columns; cur_data_all INCLUDED them. Both deprecated. pick(everything()) includes grouping columns by default in dplyr 1.1+.
Will cur_data be removed in a future dplyr version?
Possibly. It is currently soft-deprecated (warning). Future major versions may remove it entirely. Migrate proactively.
Can I use cur_data_id?
There is no cur_data_id. You may be thinking of cur_group_id, which returns an integer. cur_data and cur_data_all both returned a tibble.