Re: [R] Concatenate two lists replacing elements with the same name.

2016-07-20 Thread Luca Cerone
thanks a lot for the help! On Tue, Jul 19, 2016 at 7:20 PM, Gabor Grothendieck wrote: > Try this: > > Reduce(modifyList, list(x, y, z)) > > On Tue, Jul 19, 2016 at 12:34 PM, Luca Cerone wrote: >> Dear all, >> I would like to know if there is a function to concatenate two lists >> while repla

Re: [R] Concatenate two lists replacing elements with the same name.

2016-07-19 Thread Gabor Grothendieck
Try this: Reduce(modifyList, list(x, y, z)) On Tue, Jul 19, 2016 at 12:34 PM, Luca Cerone wrote: > Dear all, > I would like to know if there is a function to concatenate two lists > while replacing elements with the same name. > > For example: > > x <- list(a=1,b=2,c=3) > y <- list( b=4, d=5

Re: [R] Concatenate two lists replacing elements with the same name.

2016-07-19 Thread William Dunlap via R-help
concatfun <- function(...) { Reduce(f=function(a,b){ a[names(b)] <- b ; a },x=list(...), init=list()) } Bill Dunlap TIBCO Software wdunlap tibco.com On Tue, Jul 19, 2016 at 9:34 AM, Luca Cerone wrote: > Dear all, > I would like to know if there is a function to concatenate two lists > while

[R] Concatenate two lists replacing elements with the same name.

2016-07-19 Thread Luca Cerone
Dear all, I would like to know if there is a function to concatenate two lists while replacing elements with the same name. For example: x <- list(a=1,b=2,c=3) y <- list( b=4, d=5) z <- list(a = 6, b = 8, e= 7) I am looking for a function "concatfun" so that u <- concatfun(x,y,z) returns: u$a