magrittr: 管道语法
magrittr: pipe
lhs %>% rhs forward-pipe
- lhs为rhs第一个参数时:
x %>% f(y)等价于 f(x, y) - lhs在任意位置时,用点(.)代替:
z %>% f(x, y, arg = .)等价于 f(x, y, arg = z) - rhs为代码块:
rnorm(100) %>% {c(min(.), mean(.), max(.))} %>% floor
lhs %<>% rhs复合赋值管道运算符
%<>%用于首先将lhs传递给rhs表达式,最后将值重新赋给lhs。some_object %<>% foo %>% bar
相当于some_object <- some_object %>% foo %>% bar
lhs %$% rhs
iris %>% |
lhs %T>% rhs T运算符
返回lhs本身,而不是rhs函数或表达式,对于print或者plot类似函数非常有用。
rnorm(200)%>% |
评论










