Skip to contents

Matrix intersections

Usage

matrix_intersect(x, y, false = "", fn = function(x, y) x == y)

matrix_anti_join(x, y, false = "", fn = function(x, y) x == y)

matrix_join(x, y, false = "", fn = function(z) z != false)

Arguments

x

A matrix

y

A matrix

false

The value to use when fn evaluates to FALSE

fn

A function to compare the matrices

Examples

x <- matrix(sample(c('', '@'), 10, replace = TRUE), 2) |> print()
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,] ""   ""   ""   "@"  ""  
#> [2,] ""   ""   ""   ""   "@" 
y <- matrix(sample(c('', '@'), 10, replace = TRUE), 2) |> print()
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,] "@"  ""   ""   "@"  "@" 
#> [2,] "@"  "@"  ""   ""   "@" 

matrix_intersect(x, y)
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,] ""   ""   ""   "@"  ""  
#> [2,] ""   ""   ""   ""   "@" 
matrix_join(x, y)
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,] "@"  ""   ""   "@"  "@" 
#> [2,] "@"  "@"  ""   ""   "@" 
matrix_anti_join(x, y)
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,] ""   ""   ""   ""   ""  
#> [2,] ""   ""   ""   ""   ""