检查magrittr软件包,因为它似乎最接近您的要求。维基百科引用了一个例子:
例如,使用如下应用语言的一系列操作:
def example(x): y = foo(x) z = bar(y) w = baz(z) return w
...以无点样式写成,是由一系列功能组成的,没有参数:
def example: baz bar foo
在R中,magrittr
它可以写成
x %>% foo %>% bar %>% baz
其中%>%
操作者用于撰写的功能的链,从而使前一函数的输出作为后续函数的第一个参数传递。有关magrittr
更多信息,请参见插图。
该功能可以定义
# explicitly
example <- function(x) x %>% foo %>% bar %>% baz
# or simply (as @bergant noticed)
example <- . %>% foo %>% bar %>% baz
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句