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

Luca Cerone luca.cerone at gmail.com
Tue Jul 19 18:34:38 CEST 2016


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=6
u$b=8
u$c=3
u$d=5
u$e=7

I.e. it combines the 3 lists, but when names have the same value it
keeps the most recent one.

Does such a function exists?

Thanks for the help,

Cheers,
Luca



More information about the R-help mailing list