-
Notifications
You must be signed in to change notification settings - Fork 0
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
Wrap f_*
functions as methods
#1
Comments
Thanks for the comments, I like the idea though I'll need to think a bit more about that one! Part of my motivation was to avoid having the user to perform conversions, hence why I opted for alternative names that were explicit in the fact that they're different from dplyr. One could argue that writing methods like, e.g. On the other hand I can see how this might be quite powerful and make the code more readable, especially to those familiar with dplyr already. Regarding the implementation, I'm assuming it's similar to the tidytable package where all that's needed is to create a new I have just submitted 0.1.0 to CRAN (pending acceptance), so any changes like this will go in one of the next versions. |
@NicChr Of course, you can keep all as_fastplyr <- function(.data, ...) {
UseMethod("as_fastplyr")
}
as_fastplyr.data.frame <- function(.data) {
if ("fastplyr" %in% class(.data)) {
return(.data)
}
class(.data) <- c("fastplyr", class(.data))
return(.data)
}
distinct.fastplyr <- function(...) {
as_fastplyr(f_distinct(...))
} |
I'm not sure 'fastplyr' conveys that it's a type of tbl, maybe something like 'fp_tbl' or 'fastplyr_tbl'? |
As I started writing some of the code for these S3 wrappers I realised that since not all of the dplyr functions are s3 methods, e.g. |
Unfortunately, yes, you are right. |
As most
dplyr
functions are S3 methods (to be used for other backends, such asdata.table
fordtplyr
andduckdb
forduckplyr
)https://github.com/tidyverse/dplyr/blob/1d17672a54305170dc75c251f8ae69a85c0bea37/R/distinct.R#L68-L70
https://duckplyr.tidyverse.org/reference/as_duckplyr_df.html
I was thinking it would be possible to create a new S3 class, e.g.
fastplyr
, and wrap allf_*
functions as*.fastplyr
, e.g.f_distinct
asdistinct.fastplyr
.Ultimately, one would then use this package almost as a drop-in replacement of dplyr.
If you think that is a good idea, I could explore a bit.
The text was updated successfully, but these errors were encountered: