[R] Partial loop?

Hesen Peng hesen.peng at gmail.com
Sat Jun 27 09:38:16 CEST 2009


Finally I ended up doing this:

temp <- expand.grid(1:n,1:n)
temp<-temp[temp[,1]>temp[,2]]

apply(temp,1, ... )

and it seems much faster :)

On Sat, Jun 27, 2009 at 3:26 PM, Patrick Burns<pburns at pburns.seanet.com> wrote:
> See 'The R Inferno'.
>
>
>
> Patrick Burns
> patrick at burns-stat.com
> +44 (0)20 8525 0696
> http://www.burns-stat.com
> (home of "The R Inferno" and "A Guide for the Unwilling S User")
>
>
> Hesen Peng wrote:
>>
>> My dear R buddies,
>>
>> I'm writing a loop program like this:
>>
>> for(i in 1:n){
>>   for(j in 1:i){
>>    ...
>>   }
>> }
>>
>> I wonder if there is any simple apply()-like function to make the loop
>> a little bit easier and faster. Thanks a lot.
>>
>> Best wishes,
>>
>



-- 
彭河森 Hesen Peng
http://hesen.peng.googlepages.com/




More information about the R-help mailing list