b-rodrigues / chronicler

https://b-rodrigues.github.io/chronicler/
GNU General Public License v3.0
50 stars 4 forks source link

Implicitly embellish the functions via pipe? #10

Open iqis opened 1 year ago

iqis commented 1 year ago

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 commented 1 year ago

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.