[R] do.call vs. lapply for lists

2007-04-09 Thread Muenchen, Robert A (Bob)
Hi All, I'm trying to understand the difference between do.call and lapply for applying a function to a list. Below is one of the variations of programs (by Marc Schwartz) discussed here recently to select the first and last n observations per group. I've looked in several books, the R FAQ and

Re: [R] do.call vs. lapply for lists

2007-04-09 Thread jim holtman
On 4/9/07, Muenchen, Robert A (Bob) [EMAIL PROTECTED] wrote: Hi All, I'm trying to understand the difference between do.call and lapply for applying a function to a list. Below is one of the variations of programs (by Marc Schwartz) discussed here recently to select the first and last n

Re: [R] do.call vs. lapply for lists

2007-04-09 Thread Marc Schwartz
On Mon, 2007-04-09 at 12:45 -0400, Muenchen, Robert A (Bob) wrote: Hi All, I'm trying to understand the difference between do.call and lapply for applying a function to a list. Below is one of the variations of programs (by Marc Schwartz) discussed here recently to select the first and last

Re: [R] do.call vs. lapply for lists

2007-04-09 Thread Muenchen, Robert A (Bob)
Marc, That makes the difference between do.call and lapply crystal clear. Your explanation would make a nice FAQ entry. Thanks! Bob = Bob Muenchen (pronounced Min'-chen), Manager Statistical Consulting Center U of TN Office of

Re: [R] do.call vs. lapply for lists

2007-04-09 Thread Gabor Grothendieck
Consider this. If L is a list with n components then - do.call(f, L) calls f once - lapply(L, f) calls f n times On 4/9/07, Muenchen, Robert A (Bob) [EMAIL PROTECTED] wrote: Hi All, I'm trying to understand the difference between do.call and lapply for applying a function to a list. Below