Re: [R] Odp: Programming: loop versus vector oriented

2010-09-20 Thread Petr PIKAL
Hi Jan r-help-boun...@r-project.org napsal dne 17.09.2010 12:43:40: Hello Petr, but I think this is how your code really works. Did you try it? it does, but the R documentation says somewhere: Warning: for() loops are used in R code much less often than in compiled languages. Code that

Re: [R] Odp: Programming: loop versus vector oriented

2010-09-20 Thread Petr PIKAL
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

Re: [R] Odp: Programming: loop versus vector oriented

2010-09-18 Thread Jan private
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)) *

Re: [R] Odp: Programming: loop versus vector oriented

2010-09-17 Thread Petr PIKAL
Hi Jan but I think this is how your code really works. Did you try it? Regards Petr Jan private jrheinlaen...@gmx.de napsal dne 16.09.2010 13:22:05: Hello Petr, If you want to get results of your function for a vector of reynolds and dk you can use function outer and probably get rid

Re: [R] Odp: Programming: loop versus vector oriented

2010-09-17 Thread Petr PIKAL
Hi Jan Jan private jrheinlaen...@gmx.de napsal dne 17.09.2010 12:43:40: Hello Petr, but I think this is how your code really works. Did you try it? it does, but the R documentation says somewhere: Warning: for() loops are used in R code much less often than in compiled languages. Code

Re: [R] Odp: Programming: loop versus vector oriented

2010-09-17 Thread Jan private
Hello Petr, but I think this is how your code really works. Did you try it? it does, but the R documentation says somewhere: Warning: for() loops are used in R code much less often than in compiled languages. Code that takes a `whole object' view is likely to be both clearer and faster in R.

Re: [R] Odp: Programming: loop versus vector oriented

2010-09-16 Thread Jan private
Hello Petr, If you want to get results of your function for a vector of reynolds and dk you can use function outer and probably get rid of for cycle in the function. outer(c(100, 530,2410), c(10, 150,200),lambda_wall) [,1] [,2] [,3] [1,] 0.640 0.6400

[R] Odp: Programming: loop versus vector oriented

2010-09-15 Thread Petr PIKAL
Hi I do not want to go too much deep to internals of your function. What do you suppose to get as the result. If you want to get results of your function for a vector of reynolds and dk you can use function outer and probably get rid of for cycle in the function. outer(c(100, 530,2410),