Possible Duplicate:
R Pipelining functions
I find R syntax very unwieldy compared to F#:
In R - Instead of:
plot(exp(cumsum(returns)))
I would love to do
returns |> cumsum |> exp |> plot
Is there a way to overload an operator in R to achieve a similar effect?
thanks
sure, why not,
`%|>%` = function(x, y) y(x)
1:10 %|>% cumsum %|>% plot
Stolen from the Reduce
help page:
Funcall <- function(f, ...) f(...)
Reduce(Funcall, list(plot, exp, cumsum), 1:10, right = TRUE)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With