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

Description Usage Arguments Examples

View source: R/list.join.R

Description

Join two lists by single or multiple keys

Usage

1
list.join(x, y, xkey, ykey, ..., 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 missing

...

The additional parameters passed to merge.data.frame

keep.order

Should the order of x be kept?

Examples

1
2
3
4
5
6
7
8
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=22,type='A'))
list.join(l1, l2, name)
list.join(l1, l2, .[c('name','age')])

Example output

$p1
$p1$name
[1] "Ken"

$p1$age
[1] 20

$p1$type
[1] "B"


$p2
$p2$name
[1] "James"

$p2$age
[1] 22

$p2$type
[1] "A"


$p3
$p3$name
[1] "Jenny"

$p3$age
[1] 20

$p3$type
[1] "A"


$p1
$p1$name
[1] "Ken"

$p1$age
[1] 20

$p1$type
[1] "B"


$p3
$p3$name
[1] "Jenny"

$p3$age
[1] 20

$p3$type
[1] "A"

rlist documentation built on Sept. 5, 2021, 5:30 p.m.