Re: [R] Replace two nested loop with an apply kind of function

2013-08-25 Thread ginan
Dear Professor, thank you very much your suggestion. Yes, the real problem is the speed. I will check and try to understand how to use that R package, although it seems that it requires some knowledge of C++. Thank you very much once again, gul > The only reason to use one of the apply famil

Re: [R] Replace two nested loop with an apply kind of function

2013-08-24 Thread Mark Sharp
The only reason to use one of the apply family of functions is because the idiom makes your code more clear. I do not see how that would be the case here. The apply functions are not typically any faster. If you really need speed the Rcpp package is very easy to use. Mark On Aug 23, 2013, at 3:

Re: [R] Replace two nested loop with an apply kind of function

2013-08-24 Thread Mark Sharp
On Aug 23, 2013, at 3:33 PM, gi...@metu.edu.tr wrote: Dear R users, I am confused with the usage of apply kind of functions instead of nested loops. Let me illustrate my problem, I have an array,named C, with dimesions c(nr,nr,nt*n). I want to fill in a Tmat array acc

[R] Replace two nested loop with an apply kind of function

2013-08-23 Thread ginan
Dear R users, I am confused with the usage of apply kind of functions instead of nested loops. Let me illustrate my problem, I have an array,named C, with dimesions c(nr,nr,nt*n). I want to fill in a Tmat array according to the rule as given below: Tmat<-array(diag(nt*nr), c(nt*nr,nt*nr,n)) fo