[R] R - MATLAB apply like function
Hans W. Borchers
hwborchers at gmail.com
Wed Mar 4 10:06:30 CET 2009
ARDIA David <david.ardia <at> unifr.ch> writes:
>
> Dear all,
> I very often use the R function "apply", for speedup purposes. I am now also
> using MATLAB, and would like to use the same kind of function.
> I have already asked MATLAB people, and the answer is : "vectorize"... but of
> course, this is not always possible. So, instead of using a FOR loop all the
> time, I tried using the bsxfun.
The only other Matlab functions I can come up with of are 'arrayfun',
'structfun', and 'cellfun'. For instance,
arrayfun(@(x)isequal(x.f1, x.f2), S)
applies an anonymous function to a structure array.
But think of it, loops in Matlab are much faster than in R -- especially since
version 2008a --, so the need for avoiding them is not as big.
Regards, Hans Werner
> So you R people, who might also use MATLAB, do you have any solution? Are you
> also nervous about this fact (maybe also because of this R-MATLAB question).
> Thanks for your help,
> Dave
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help <at> r-project.org 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.
>
>
More information about the R-help
mailing list