Skip to contents

Join operations

Usage

innerJoin(x, y, by, ...)

leftJoin(x, y, by, ...)

rightJoin(x, y, by, ...)

fullJoin(x, y, by, ...)

semiJoin(x, y, by, ...)

antiJoin(x, y, by, ...)

# S4 method for DFrame,DFrame,character
antiJoin(x, y, by)

# S4 method for DFrame,DFrame,character
fullJoin(x, y, by)

# S4 method for DFrame,DFrame,character
innerJoin(x, y, by)

# S4 method for DFrame,DFrame,character
leftJoin(x, y, by)

# S4 method for DFrame,DFrame,character
rightJoin(x, y, by)

# S4 method for DFrame,DFrame,character
semiJoin(x, y, by)

Arguments

x

Object.

y

Object.

by

character. Column names to use for join operation.

...

Additional arguments.

Value

New object containing a merge of x and y objects.

Note

Updated 2023-10-12.

Ordering

The join functions never rearrange rows. To accomplish this, we're currently setting an internal .idx column that we can use to reorder the rows after merge() operation.

Row names

Unlike the S3 methods defined in dplyr, the join methods defined here for DFrame always preserve row names.

See also

These functions are inspired by dplyr. However, they are designed to only work on Bioconductor S4 class objects, and use base R code internally.

Examples

data(join, package = "AcidTest")

## DFrame ====
x <- as(join[["members"]], "DFrame")
print(x)
#> DataFrame with 3 rows and 2 columns
#>          name        band
#>   <character> <character>
#> 1        Mick      Stones
#> 2        John     Beatles
#> 3        Paul     Beatles
y <- as(join[["instruments"]], "DFrame")
print(y)
#> DataFrame with 3 rows and 2 columns
#>          name       plays
#>   <character> <character>
#> 1        John      guitar
#> 2        Paul        bass
#> 3       Keith      guitar
by <- "name"
innerJoin(x = x, y = y, by = by)
#> DataFrame with 2 rows and 3 columns
#>          name        band       plays
#>   <character> <character> <character>
#> 1        John     Beatles      guitar
#> 2        Paul     Beatles        bass
leftJoin(x = x, y = y, by = by)
#> DataFrame with 3 rows and 3 columns
#>          name        band       plays
#>   <character> <character> <character>
#> 1        Mick      Stones          NA
#> 2        John     Beatles      guitar
#> 3        Paul     Beatles        bass
rightJoin(x = x, y = y, by = by)
#> DataFrame with 3 rows and 3 columns
#>          name       plays        band
#>   <character> <character> <character>
#> 1        John      guitar     Beatles
#> 2        Paul        bass     Beatles
#> 3       Keith      guitar          NA
fullJoin(x = x, y = y, by = by)
#> DataFrame with 4 rows and 3 columns
#>          name        band       plays
#>   <character> <character> <character>
#> 1        Mick      Stones          NA
#> 2        John     Beatles      guitar
#> 3        Paul     Beatles        bass
#> 4       Keith          NA      guitar
semiJoin(x = x, y = y, by = by)
#> DataFrame with 2 rows and 2 columns
#>          name        band
#>   <character> <character>
#> 1        John     Beatles
#> 2        Paul     Beatles
antiJoin(x = x, y = y, by = by)
#> DataFrame with 1 row and 2 columns
#>          name        band
#>   <character> <character>
#> 1        Mick      Stones