[R] alternative to matching/merge?

Lana Schaffer schaffer at scripps.edu
Tue Jun 17 01:36:54 CEST 2008


Jim,
Is it possible to do a do.call(rbind,d.frame) with a list
like using lapply(data,func,args)?
I have not successfully executed this.
Lana 

-----Original Message-----
From: hadley wickham [mailto:h.wickham at gmail.com] 
Sent: Friday, June 13, 2008 2:54 PM
To: jim holtman
Cc: Lana Schaffer; r-help at r-project.org
Subject: Re: [R] alternative to matching/merge?

On Fri, Jun 13, 2008 at 11:45 AM, jim holtman <jholtman at gmail.com>
wrote:
> What is the structure of 'd.frame' and 'segFile'?  Run Rprof so that 
> we can see which of the functions it is spending its time in.  What 
> happens if x$index is not in seqFile$index?  Are the values in the 
> 'index' unique in both structures?  Subsetting a data frame can be 
> expensive when compared to using a matrix.  Could you use a matrix 
> instead of a data frame; are all the columns the same mode?  Again 
> either a subset of data would be helpful or an 'str' on the data 
> objects being used so that we can understand what they are.

A few other ideas to try:

 * try merging do.call("rbind", d.frame) and seqFile, and then spliting
the results back up

 * try turning giving seqFile rownames (rownames(seqFile) <-
seqFile$index) and then use character matching:  cbind(x, seqFile[
as.character(x$index)]

 * if there is a one to one corresponding between index in seqFile and
all data.frames in d.frame, merge all of the d.frames together, order
both by index then just cbind

Hadley


--
http://had.co.nz/



More information about the R-help mailing list