krlmlr/kimisc

Feature request: could format_fun support a purrr style lambda?

Closed this issue · 3 comments

Thanks for the useful cut_format function!

Is it possible that the format_fun argument in cut_format could support a purrr style lambda?

library(kimisc)
#this works
cut_format(runif(10), seq(0, 1, by = 0.25), 
           format_fun = function(x) paste(x * 100, "%"))

#this doesn't, but it'd be great if it did
cut_format(runif(10), seq(0, 1, by = 0.25), 
           format_fun = ~ paste(.x * 100, "%"))

Thanks. The excellent {santoku} package is dedicated to binning, it might support what you're looking for. (?cut_format should really point there too.)

Oh I hadn't seen that package, thanks!

Just to check, is kimisc::cut_format going to stick around?

I've built a package on CRAN that currently has it as a dependency

I've moved to using {santoku} instead - thanks!