merge.Rcpp_Hashmap: Merge two Hashmaps

Description Usage Arguments Details Value Examples

Description

merge method for Hashmap class

Usage

1
2
3
## S3 method for class 'Rcpp_Hashmap'
merge(x, y, type = c("inner", "left", "right", "full"),
  ...)

Arguments

x

an object created by a call to hashmap.

y

an object created by a call to hashmap.

type

a character string specifying the type of join, with partial argument matching (abbreviation) supported.

...

not used.

Details

Valid arguments for type are:

The default value for type is "inner".

Value

a data.frame.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
hx <- hashmap(LETTERS[1:5], 1:5)
hy <- hashmap(LETTERS[4:8], 4:8)

## inner join
merge(hx, hy)

merge(
    hx$data.frame(),
    hy$data.frame(),
    by = "Keys",
    sort = FALSE
)

## left join
merge(hx, hy, "left")

merge(
    hx$data.frame(),
    hy$data.frame(),
    by = "Keys",
    all.x = TRUE,
    sort = FALSE
)

## right join
merge(hx, hy, "right")

merge(
    hx$data.frame(),
    hy$data.frame(),
    by = "Keys",
    all.y = TRUE,
    sort = FALSE
)

## full outer join
merge(hx, hy, "full")

merge(
    hx$data.frame(),
    hy$data.frame(),
    by = "Keys",
    all = TRUE,
    sort = FALSE
)

Example output

  Keys Values.x Values.y
1    D        4        4
2    E        5        5
  Keys Values.x Values.y
1    D        4        4
2    E        5        5
  Keys Values.x Values.y
1    A        1       NA
2    B        2       NA
3    C        3       NA
4    D        4        4
5    E        5        5
  Keys Values.x Values.y
1    D        4        4
2    E        5        5
3    A        1       NA
4    B        2       NA
5    C        3       NA
  Keys Values.x Values.y
1    G       NA        7
2    H       NA        8
3    D        4        4
4    E        5        5
5    F       NA        6
  Keys Values.x Values.y
1    D        4        4
2    E        5        5
3    G       NA        7
4    H       NA        8
5    F       NA        6
  Keys Values.x Values.y
1    A        1       NA
2    H       NA        8
3    F       NA        6
4    G       NA        7
5    E        5        5
6    B        2       NA
7    C        3       NA
8    D        4        4
  Keys Values.x Values.y
1    D        4        4
2    E        5        5
3    A        1       NA
4    B        2       NA
5    C        3       NA
6    G       NA        7
7    H       NA        8
8    F       NA        6

hashmap documentation built on May 1, 2019, 10:13 p.m.