Re: [R] for() to lapply()

About this list Date view Thread view Subject view Author view Attachment view

From: Jason Turner (jasont@indigoindustrial.co.nz)
Date: Fri 21 May 2004 - 10:43:56 EST


Message-id: <20040521004356.GA4952@kryten.akl.indigoindustrial.co.nz>

On Thu, May 20, 2004 at 03:52:22PM -0500, Kenneth Cabrera wrote:
> Hi dear R-users:
>
> I have the following problem:
> I have a list of data.frames (12 variables and 60000 rows, each)
>
> I have to merge from an specific point of the list to the
> end of the list, I am doing so with a for() loop but it is
> too inefficient and it exhausts memory.
>
> How can I convert this for() loop in a function and then use
> lapply?

There's still a better way to do it, I'm sure, but something
like...

##untested!

myMerge <- function(x,y,...) {
        zz <- merge(x,y,...)
        gc()
}

foo <- lapply(my.df.list[[-1]],myMerge,my.df.list[[1]])

Cheers

Jason

-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
jasont@indigoindustrial.co.nz

______________________________________________ R-help@stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:11 EST