R Pipelining functions

前端 未结 5 1990
北荒
北荒 2020-12-10 12:14

Is there a way to write pipelined functions in R where the result of one function passes immediately into the next? I\'m coming from F# and really appreciated this ability b

5条回答
  •  Happy的楠姐
    2020-12-10 12:50

    This works for R pretty similar in F#:

    "%|>%" <- function(x, fun){
        if(is.function(x)) {
          function(...) fun(x(...))
        } else {
          fun(x)
        }
    }
    

提交回复
热议问题