Hi Jan Jan private <jrheinlaen...@gmx.de> napsal dne 18.09.2010 12:12:29:
> Hello Petr, > > thank you for your ideas. The split() looks most realistic. > > What about this idea: > > 1. Define three functions Refun1, Refun2, Refun3 for the three different > sections of the calculations (same as you suggested) > 2. lambda = (Re <= 2320) * Refun1(Re) + ((Re > 2320) && (Re < 65 * dk)) > * Refun2(Re) etc. > > But my thought is that probably the values of RefunXYZ will be > calculated for every value of Re, even if the condition (Re <= 2320) is > FALSE (= 0). So that would give a lot of unnecessary function > evaluations. Probably yes but it could be only small overhead and you can check speed by system.time(result1 <- your function1) system.time(result2 <- your function2) all.equal(result1, result2) If you do not perceive differences you can wrap function into some loop and let it perform several times inside system.time call Regards Petr > > Regards, > Jan > > ______________________________________________ R-help@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.