What and where are commonly useful function operators?



Function operators (FOs) seem like a great way to increase productivity and make the best of R's functional programming chops, perhaps especially in package development.
Keeps functions nice and small, without having to built a gazillion wrappers and passing around arguments like a crazy person.

In @hadley's words:

A function operator is a function that takes one (or more) functions as input and returns a function as output.

(More details here).

Ideally, of course, I don't want to write many FOs myself, but increase my usage of existing FOs from other packages.

My questions are:

  1. What function operators do you recommend and/or find useful?
  2. What good sources (packages?) for function operators are out there?
  3. If this is a stupid question or a bad idea (... "pointless programming"), please set me straight.

For example, I'm looking for an FO which captures file outputs of functions.


I'm aware of some, but was wondering whether there might be more:

  • base R has some, of course, including base::Negate()
  • purrr also has a bunch, of course (called adverbs), such as purrr::possibly()
  • good old plyr also has some, such as plyr::failwith().
  • then there's memoise
  • functools also lists a bunch of FOs, but I'm not familiar with that package.


I would like to add to your list

  • the solutions to Hadley Wickham’s book "Advanced R" contributed by Malte Grosser, Henning Bumann, Peter Hurford and Robert Krzyzanowski (see chapters: Behavioural FOs, Output FOs, Input FOs, Combining FOs)


that's a great resource, thanks for pointing me to that!