Re: [R] curious about dimension of 'apply' output when MARGIN=1

From: Benjamin Tyner <btyner_at_stat.purdue.edu>
Date: Thu 18 Jan 2007 - 14:16:27 GMT

Thanks to all for your insightful comments. I must admit I was unaware of the application to arrays.

Ben

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.



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri Jan 19 01:24:53 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 18 Jan 2007 - 14:30:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.