Function Composition in R (and high level functions)

后端 未结 3 959
执笔经年
执笔经年 2021-02-19 01:28

Is there something like a function composition in R?

I think in haskell it\'s somthing like \"(.)\" and in agda it\'s the ring operator.

Also, I find litte infor

3条回答
  •  野的像风
    2021-02-19 02:06

    You may make compositing function like this:

    composite<-function(f,g) function(...) f(g(...))
    
    f<-function(x) x+1;
    g<-function(x) x*2;
    composite(f,g)(7)
    composite(g,f)(7)
    

    or make operator of this.

    About the second point, there are lots of such; I think the most used are the *apply family (sapply, mapply, tapply, lapply, apply...).

提交回复
热议问题