[R] curious about dimension of 'apply' output when MARGIN=1
btyner at stat.purdue.edu
Thu Jan 18 15:16:27 CET 2007
Thanks to all for your insightful comments. I must admit I was unaware
of the application to arrays.
Prof Brian Ripley wrote:
> Or that the vision of the original designer was not limited to
> matrices. It just so happens that in this example the replacement is a
> single dimension the same size as the single margin used. That's
> atypical, and normally the result dimension has no connection to the
> margin. The design is to put the result dimension first, and the
> first item in the 'seealso' list is aperm().
> To my mind the only general solutions are to put the result dimension
> first or last. I would have used last, but using first is slightly
> more efficient for the reason Pat gives.
> apply() is for arrays, operating over one or more margins with a
> function returning a 'scalar', vector or array result. Perhaps any
> 'lazy'-ness / limit of vision is not in handling array results as well
> as might be possible.
More information about the R-help