Learn R Programming

rlist (version 0.2.3)

list.join: Join two lists by single or multiple keys

Description

Join two lists by single or multiple keys

Usage

list.join(x, y, xkey, ykey = NULL, ..., keep.order = TRUE)

Arguments

x
The first list
y
The second list
xkey
A lambda expression that determines the key for list x
ykey
A lambda expression that determines the key for list y, same to xkey if NULL is taken
...
The additional parameters passed to merge.data.frame
keep.order
Should the order of x be kept?

Examples

Run this code
l1 <- list(p1=list(name="Ken",age=20),
       p2=list(name="James",age=21),
       p3=list(name="Jenny",age=20))
l2 <- list(p1=list(name="Jenny",age=20,type="A"),
       p2=list(name="Ken",age=20,type="B"),
       p3=list(name="James",age=21,type="A"))
list.join(l1,l2,name)
list.join(l1,l2,.["name","age"])

Run the code above in your browser using DataLab