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

Implicitly embellish the functions via pipe? #10

Open
iqis opened this issue Feb 8, 2023 · 1 comment
Open

Implicitly embellish the functions via pipe? #10

iqis opened this issue Feb 8, 2023 · 1 comment

Comments

@iqis
Copy link

iqis commented Feb 8, 2023

A colleague of mine pointed me towards this package. I think this is awesome.

A question to the authors:
If the fishbone pipe %>=% is already incorporating bind , why not make another (or the same) that also do map?
This way the functions do not have to be explicitly embellished.

This

r_group_by <- record(group_by)
r_select <- record(select, .g = dim)
r_summarise <- record(summarise, .g = dim)
r_filter <- record(filter, .g = dim)

output_pipe <- starwars %>%
  r_select(height, mass, species, sex) %>=%
  r_group_by(species, sex) %>=%
  r_filter(sex != "male") %>=%
  r_summarise(mass = mean(mass, na.rm = TRUE))

can become

output_pipe <- starwars %>=>%
  select(height, mass, species, sex) %>=>%
  group_by(species, sex) %>=>%
  filter(sex != "male") %>=>%
  summarise(mass = mean(mass, na.rm = TRUE))
@b-rodrigues
Copy link
Owner

Many thanks for your kind words!
I thought about doing something like this, but then settled for record_many() instead. The reason is that this way you define them once, instead of doing the embellishment each time, which adds some overhead.

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

No branches or pull requests

2 participants