Summarise gives Internal error in `df_slice()`: Columns must match the data frame size.

The code below gives the error message

Error: Problem with `summarise()` column `xxx`.
i `xxx = nrow(filter(cur_data(), abc2 > 0))`.
x Internal error in `df_slice()`: Columns must match the data frame size.

lookAhead = 2
colnm = sym(glue("abc{lookAhead}"))

df <- data.frame(abc1 = rnorm(5), abc2 = rnorm(5))

df %>% 
  summarise(n  = n(), 
            xxx = nrow(filter(cur_data(), {{colnm}}>0))

Reversing the two summarise parameters fixes the problem.

Any ideas what the error means here?

(Attribution: Thanks to Ronak Shah for his efforts of getting my original problem down to this state.)

seems like a bug, that should be raised as an issue to give the dplyr team an opportunity to look at it.
sidenote that the following change appears to work, and gives the same result, not sure if in a larger or more complex setting it would suffice though...

df %>% 
    n  = n(),
   xxx = nrow(filter(.
                     , {{colnm}}>0))



df %>% 
    n  = n(),
   xxx = nrow(filter(,


something odd going on down in vctrs::vec_slice

Many thanks, will raise as requested.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.