Description Usage Arguments Details Value
The ordinary version of 'apply' have the undesirable property that
it always squashes the result of its function-argument into a
vector, which implies that the dimension and dimension-names get
lost in translation. This revised version of apply
does not
perform such despicable deeds. UPDATE: It does however turn out to
be exceptionally inefficient when compared with 'apply', so this
attempt can't be considered a success... I guess the better option
should be to create a minor tweak that ensures that we reformat the
matrix into the desired format instead... UPDATE, 2015-05-14, this
had to be done since 'aaply' did not want to cooperate with one of
the cases I wanted to use, check the function 'my_aaply' for
details.
1 2 |
X, |
|
MARGIN, |
|
FUN, |
|
..., |
|
.list, |
|
.front, |
|
.parallel, |
|
.cores, |
|
I think I see the reason now... The stuff I made below will over and over again create an array with the size of the result, and that does not work very well since it induces a very high overhead for every single part of the loop.. Could this be avoided? Beats me. The idea of modifying the output instead now looks like the most promising option. That might indeed be done very simple I think, since it could boil down to just changing the dimensions to the desired format. After doing that, I guess I could include the dimension-names and so on.
This function returns an array with dimensions specified by
those given in MARGIN
and those originating from the result
of FUN
. If FUN
returns a single value without any
name, e.g. like sum
does, then only the dimensions from
MARGIN
are used. Otherwise new dimensions are added, either
in the "front" or the "end" depending on the value of .front
(the default is in the "front"). The resulting array will inherit
the names and dimension-names from X
that MARGIN
refers to, and similarly from the result of FUN
.
Dimension-names will be added if X
and the result of
FUN
does not have them. The parts from X
and
FUN
will then respectively be baptised with "orig_#" and
"result_#", where "#" runs over the available dimensions.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.