[R] apply a function on elements of a list two by two

2010-05-08 Thread Joris Meys
Dear all, I want to apply a function to list elements, two by two. I hoped that combn would help me out, but I can't get it to work. A nested for-loop works, but seems highly inefficient when you have large lists. Is there a more efficient way of approaching this? # Make some toy data data(iris)

Re: [R] apply a function on elements of a list two by two

2010-05-08 Thread David Winsemius
On May 8, 2010, at 9:43 AM, Joris Meys wrote: Dear all, I want to apply a function to list elements, two by two. I hoped that combn would help me out, but I can't get it to work. A nested for-loop works, but seems highly inefficient when you have large lists. Is there a more efficient

Re: [R] apply a function on elements of a list two by two

2010-05-08 Thread Patrick Hausmann
Am 08.05.2010 15:43, schrieb Joris Meys: Dear all, I want to apply a function to list elements, two by two. I hoped that combn would help me out, but I can't get it to work. A nested for-loop works, but seems highly inefficient when you have large lists. Is there a more efficient way of

Re: [R] apply a function on elements of a list two by two

2010-05-08 Thread Joris Meys
Thx, works like a charm. And indeed, I didn't realize combn could be that powerful. Thx for pointing that out. @ Patrick : thanks for the tip. It was just a fast coded toy example, but it never hurts to get reminded about the more efficient way, even with toy examples. Cheers Joris On Sat, May