I have two lists, whose elements have partially overlapping names, which I need to merge/combine together into a single list, element by element:
My question is rela
Here you go in 3 lines:
out <- l.1 mnames <- intersect(names(l.1),names(l.2)) out[mnames] <- Map(function(a,b) Map(c,a,b),l.1[mnames],l.2[mnames]) #$a #$a[[1]] #[1] 10 20 #$a[[2]] #[1] 1 0 # #$b #$b[[1]] #[1] 10 20 30 #$b[[2]] #[1] 1 2 3 # #$c #$c[[1]] #[1] 9 12 13 #$c[[2]] #NULL