Skip to content

Conversation

@hrryt
Copy link

@hrryt hrryt commented May 18, 2025

Fixes #1490.

Snags:

  1. In the absence of both cols and by, should we 'chop everything' as nest() does? I have thrown an error instead.
  2. Should chop() use group vars if data is grouped, as nest() does? Would this require a generic?
  3. What should happen if a column is selected by both cols and by? For now, the name is duplicated and repaired.

An example for the latter point:

df <- tibble(x = c(1, 1, 1, 2, 2), y = c(2, 1, 2, 3, 4), z = 1:5) nest(df, data = everything(), .by = y) #> # A tibble: 4 × 2 #> y data  #> <dbl> <list>  #> 1 2 <tibble [2 × 3]> #> 2 1 <tibble [1 × 3]> #> 3 3 <tibble [1 × 3]> #> 4 4 <tibble [1 × 3]> chop(df, everything(), by = y) #> New names: #> • `y` -> `y...1` #> • `y` -> `y...3` #> # A tibble: 4 × 4 #> y...1 x y...3 z #> <dbl> <list<dbl>> <list<dbl>> <list<int>> #> 1 2 [2] [2] [2] #> 2 1 [1] [1] [1] #> 3 3 [1] [1] [1] #> 4 4 [1] [1] [1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant