[R] Merge selected list element by name
Rui Barradas
ruipbarradas at sapo.pt
Thu Apr 13 18:37:06 CEST 2017
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
>
> Göteborg, Sweden | mashranga at yahoo.com
>
> ______________________________________________
> R-help at 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.
>
More information about the R-help
mailing list