So do you mean like this: > kk<- list (a = 1:5, b = 6:10, c = 4:11) > kk1 <- list(union(kk$a,kk$c),kk$b) > names(kk1)<- c(paste(names(kk)[c(1,3)],collapse="_"),names(kk)[2]) > kk1 $a_c [1] 1 2 3 4 5 6 7 8 9 10 11
$b [1] 6 7 8 9 10 ?? Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Thu, Apr 13, 2017 at 10:33 AM, Mohammad Tanvir Ahamed via R-help <r-help@r-project.org> wrote: > Thanks for your code. > But this is not the way i am expecting . > > I want to merge (Union) "a" and "c" and my expected output is > >> kk1 > $a_c > [1] 1 2 3 4 5 6 7 8 9 10 11 > > $b > [1] 6 7 8 9 10 > > > Note : I worte the code kk1<- list(a_c = 1:11, b = 6:10) just to show by > expected outcome. But i am expecting the resulting code will naming "a_c" by > itself also. > Hope i can make clear about problem. > > > > > Tanvir Ahamed > Göteborg, Sweden | mashra...@yahoo.com > > > > ________________________________ > From: Rui Barradas <ruipbarra...@sapo.pt> > > l...@r-project.org> > Sent: Thursday, 13 April 2017, 18:37 > Subject: Re: [R] Merge selected list element by name > > > > Hello, > > There's no need to send the same question twice, we've got it at the > first try. > Maybe I don't understand but is this it? > > kk1 <- list(a_c = union(kk$a, kk$c), b = kk$b) > kk1 > $a_c > [1] 1 2 3 4 5 6 7 8 9 10 11 > > $b > [1] 6 7 8 9 10 > > > Hope this helps, > > Rui Barradas > > > Em 13-04-2017 15:59, Mohammad Tanvir Ahamed via R-help escreveu: >> >> Hi, >> >> I have a list like >> >> kk<- list (a = 1:5, b = 6:10, c = 4:11) >> >> >> Now i want to merger (Union) the list element "a" and "c" by name . >> >> >> My expected outcome is >> >> kk1<- list(a_c = 1:11, b = 6:10) >> >> >> >> I can do it with several lines of code. But can any one have idea to do >> efficiently/ quickly on a big data with less code. >> >> Thanks in advance. >> >> >> Tanvir Ahamed >> > >> >> ______________________________________________ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > >> > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.