Is it possible to chain functions in R?
Sample data:
m <- matrix(c(1:10, 11:20), nrow = 10, ncol = 2)
For example, I would like to r
In a similar vein to Ben's answer, but allowing arguments:
`%@%` <- function(x, f) eval.parent(as.call(append(as.list(substitute(f)), list(x), 1))) x %@% mean %@% sqr # => 6.25 c(1, 2, NA, 3, 4) %@% mean(na.rm=T) %@% sqr # => 6.25 m %@% colMeans() %@% sum() # => 21