JuliaLang/julia — Issue #492: An R-like apply function
Author: dcjones
Created: 2012-02-28 23:06:07+00:00
State: open

I don't see that there is an idiomatic way to map a function across a particular axis of an array, similar to the R "apply" function.

For example, for a matrix `xs`,

apply(xs, 1, mean)
apply(xs, 2, mean)

computes row and column means, respectively, and so on.

I want to implement a few statistics functions, and this (the R approach) seems more general and elegant than writing a special version of each that takes a `dim` argument (the Matlab approach, more or less). Functions like `mean` and `median` would then be computed over every element in the array.

Obviously the analogous Julia function would have to be called something other than apply. Perhaps "amap".

Before I get too far, is this approach agreeable?