search for: plus2

Displaying 4 results from an estimated 4 matches for "plus2".

Did you mean: plus
2010 Aug 05
4
Reducing a list of functions by composition fails
Hi All, I'd like to be able to specify the ordered composition of several functions. So I defined compose: compose <- function(f,g){ function(x){f(g(x))} } and some simple test functions: plus2 <- function(x){x+2} plus3 <- function(x){x+3} plus4 <- function(x){x+4} > (compose(plus2,compose(plus3,plus4)))(3) [1] 12 Works fine. But trying to reduce a list of functions by compose fails: > Reduce(compose,list(plus2,plus3,plus4),right=TRUE)(3) Error: evaluation nested too de...
2019 Oct 05
4
should base R have a piping operator ?
...e on the right * It doesn't trigger indentation when going to the line * It creates/overwrite a `.` variable in the worksace. And it doesn't deal gracefully with some lazy evaluation edge cases such as : compose <- function(f, g) { function(x) g(f(x)) } plus1 <- function(x) x + 1 plus2 <- plus1 %.% compose(.,plus1) plus2(5) #> [1] 7 plus1 ->.; compose(.,plus1) -> .; . -> plus2 plus2(5) #> Error: C stack usage 15923776 is too close to the limit What I propose on the other hand can always substitute any existing proper pipe in their standard feature, as long as...
2019 Oct 05
0
should base R have a piping operator ?
...tation when going to the line > * It creates/overwrite a `.` variable in the worksace. > > And it doesn't deal gracefully with some lazy evaluation edge cases such as > : > > compose <- function(f, g) { function(x) g(f(x)) } > plus1 <- function(x) x + 1 > > plus2 <- plus1 %.% compose(.,plus1) > plus2(5) > #> [1] 7 > > plus1 ->.; compose(.,plus1) -> .; . -> plus2 > plus2(5) > #> Error: C stack usage 15923776 is too close to the limit > > What I propose on the other hand can always substitute any existing proper &g...
2019 Oct 05
6
should base R have a piping operator ?
Dear R-devel, The most popular piping operator sits in the package `magrittr` and is used by a huge amount of users, and imported /reexported by more and more packages too. Many workflows don't even make much sense without pipes nowadays, so the examples in the doc will use pipes, as do the README, vignettes etc. I believe base R could have a piping operator so packages can use a pipe in