> 1:10 %>>% (function(x,y) x + y)(2)
[1] 3 4 5 6 7 8 9 10 11 12
> 1:10 %>>% (function(x,y) x + y)
function(x,y) x + y
<environment: 0x000000000e7c1fd0>
> 1:10 %>>% I(function(x,y) x + y)(2)
[1] 3 4 5 6 7 8 9 10 11 12
> 1:10 %>>% I(function(x,y) x + y)
Error in expr[[1L]] : object of type 'closure' is not subsettable
This should work for building closure:
> p <- function(y) { function(x) x + y }
> 1:10 %>>% I(p(1))
Error in expr[[1L]] : object of type 'closure' is not subsettable
> 1:10 %>>% I(p(1))()
[1] 2 3 4 5 6 7 8 9 10 11
This should work for building closure: