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. 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]]
how 'bout an example. On Tue, Mar 3, 2009 at 6:20 AM, ARDIA David <david.ardia at unifr.ch> wrote:> 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. 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. >-- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis
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. > >