Last data update: 2014.03.03

R: Merging of multiple lists
mergeListsR Documentation

Merging of multiple lists

Description

The merge allows for a recursive component where the lists are compared on the subelement. If one does not contain that element it will get NA in for those parameters.

Usage

mergeLists(..., lapplyOutput = NULL)

Arguments

...

Any number of lists that you want to merge

lapplyOutput

The lapply function outputs a number of lists and this is for specifically merging all of those.

Value

Returns a list with all the given lists.

Examples

v1 <- list("a"=c(1,2), b="test 1", sublist=list(one=20:21, two=21:22))
v2 <- list("a"=c(3,4), b="test 2", sublist=list(one=10:11, two=11:12, three=1:2))
mergeLists(v1, v2)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(Gmisc)
Loading required package: Rcpp
Loading required package: htmlTable
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Gmisc/mergeLists.Rd_%03d_medium.png", width=480, height=480)
> ### Name: mergeLists
> ### Title: Merging of multiple lists
> ### Aliases: mergeLists
> 
> ### ** Examples
> 
> v1 <- list("a"=c(1,2), b="test 1", sublist=list(one=20:21, two=21:22))
> v2 <- list("a"=c(3,4), b="test 2", sublist=list(one=10:11, two=11:12, three=1:2))
> mergeLists(v1, v2)
$a
     [,1] [,2]
[1,]    1    2
[2,]    3    4

$b
[1] "test 1" "test 2"

$sublist
$sublist$one
     [,1] [,2]
[1,]   20   21
[2,]   10   11

$sublist$two
     [,1] [,2]
[1,]   21   22
[2,]   11   12

$sublist$three
     [,1] [,2]
[1,]   NA   NA
[2,]    1    2


> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>