etiennebacher / tidypolars

Get the power of polars with the syntax of the tidyverse
https://tidypolars.etiennebacher.com
Other
172 stars 3 forks source link

`group_by()` + `summarize()` error if I use groups in computations #83

Open etiennebacher opened 8 months ago

etiennebacher commented 8 months ago
library(tidypolars)
#> Registered S3 method overwritten by 'tidypolars':
#>   method                 from  
#>   print.RPolarsDataFrame polars
library(dplyr, warn.conflicts = FALSE)

df <- tibble(x = c(1, 3, 4), y = c(2, 1, 5), z = c(2, 3, 1))
df_pl <- as_polars_df(df)

df |>
  group_by(x) |>
  summarize(m = mean(c(x, y, z)))
#> # A tibble: 3 × 2
#>       x     m
#>   <dbl> <dbl>
#> 1     1  1.67
#> 2     3  2.33
#> 3     4  3.33

df_pl |>
  group_by(x) |>
  summarize(m = mean(c(x, y, z)))
#> Error in FUN(X[[i]], ...): argument "new_vars" is missing, with no default
etiennebacher commented 8 months ago

Idea for later, I should remove this line:

https://github.com/etiennebacher/tidypolars/blob/2a0b61add5c251b2b568033e31f0899c93793afa/R/summarize.R#L35

and only remove groups from the list of variables to modify in unpack_across()