Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify how I handle groups #22

Merged
merged 17 commits into from
Aug 4, 2023
Merged

Simplify how I handle groups #22

merged 17 commits into from
Aug 4, 2023

Conversation

etiennebacher
Copy link
Owner

@etiennebacher etiennebacher commented Aug 3, 2023

It is much easier to simply give a few attributes to the data when I run group_by(), then check these attributes in each function and use $groupby() + $agg() or $over() as I want. Then, just a custom print method to show groups and maintain_order argument.

TODO:

  • check that everything is good with tidyverse namespaces
  • check that all functions that can be applied per group work correctly (see commit 704f2bf)
  • fix the lazy tests (see "exceptions" in tinytest/setup.R)

@etiennebacher

This comment was marked as outdated.

@etiennebacher etiennebacher changed the title Simplify how I I handle groups Simplify how I handle groups Aug 3, 2023
@etiennebacher

This comment was marked as outdated.

@sorhawell

This comment was marked as outdated.

@sorhawell

This comment was marked as off-topic.

@etiennebacher
Copy link
Owner Author

Thanks for the investigation. I didn't understand whether you asked what the issue was here, but here's an example:

library(polars)

fake_group_by <- function(data, vars) {
  attr(data, "pl_grps") <- vars
  data
}

dat <- pl$DataFrame(iris)

# normal
attributes(fake_group_by(dat, "Species"))
#> $class
#> [1] "DataFrame"
#> 
#> $pl_grps
#> [1] "Species"

# there shouldn't be an attribute "pl_grps" here, hence the need to clone the
# data first
attributes(dat)
#> $class
#> [1] "DataFrame"
#> 
#> $pl_grps
#> [1] "Species"

Anyway, I'm just hiding the comments to save some space, thanks again ;)

@etiennebacher etiennebacher merged commit d34645b into main Aug 4, 2023
3 checks passed
@etiennebacher etiennebacher deleted the fix-group-handling branch August 4, 2023 14:27
@sorhawell
Copy link

but here's an example: ...

oh yes exactly 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants