[R] Creating a list of database names for merge.rec

David Winsemius dwinsemius at comcast.net
Thu Apr 16 17:05:22 CEST 2009


On Apr 16, 2009, at 10:41 AM, Andy Barenberg wrote:

> hello,  I am trying to merge a large number of datasets into one using
> "merge.rec".
>
>> merge.rec(db, by.x = "X", by.y = "Y")
>>
>
> where "db" is my list of datasets.  My problem is trying to create a  
> code to
> create the list "db" for all the files without missing data:   
> Currently my
> code looks like:
>
> if(any(is.na(X))){print(paste("there is an NA in dbn",i, sep=""))}  
> else {
>> db<-append(db,paste("dbn",i, sep=""))     }
>>
>
> this creates the list of names, but it creates the list of names in  
> the form
> of
>
>> c("dbn5", "dbn6",....)
>>
> where to make the merge.rec function work I need it to be of the form
>
>> dbn5,dbn6,....
>
> without the quotation marks.
>
> any easier way of doing this?

Use the function list()

dblist <- list(dblist, i)


Then use lapply with dblist as an argument.

> -- 


David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list