Re: [R] Re cursion is slow

2009-09-03 Thread Ben Bolker
Bryan Keller wrote: The following recursion is about 120 times faster in C#. I know R is not known for its speed with recursions but I'm wondering if anyone has a tip about how to speed things up in R. #T is a vector and m is a number between 1 and sum(T) A - function(T,m) { lt -

Re: [R] Re cursion is slow

2009-09-03 Thread jim holtman
Most of the time was being spent within the 'sapply' call. Here is a list from Rprof: 0 18.4 root 1. 18.4 system.time 2. . 12.9 A1 3. . . 12.9 sapply 4. . . . 12.9 lapply 5. . . . | 12.9 FUN 6. . . . | . 12.9 sapply 7. . . . | . . 12.9 lapply 8. . . . | . . .