IanW
December 21, 2021, 1:33pm
1
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.
library(tidyverse)
library(glue)
lookAhead = 2
colnm = sym(glue("abc{lookAhead}"))
set.seed(123)
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 %>%
summarise(
n = n(),
xxx = nrow(filter(.
, {{colnm}}>0))
)
also...
df %>%
summarise(
n = n(),
xxx = nrow(filter(as.data.frame(cur_data()),
{{colnm}}>0))
)
something odd going on down in vctrs::vec_slice
IanW
December 21, 2021, 5:13pm
3
Many thanks, will raise as requested.
opened 05:17PM - 21 Dec 21 UTC
closed 01:05PM - 16 Apr 22 UTC
bug
I've been asked over at [rstudio ](https://community.rstudio.com/t/summarise-giv… es-internal-error-in-df-slice-columns-must-match-the-data-frame-size/124778) to raise this possible bug report here.
---
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.
```r
library(tidyverse)
library(glue)
lookAhead = 2
colnm = sym(glue("abc{lookAhead}"))
set.seed(123)
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.
system
Closed
January 11, 2022, 5:14pm
4
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.