Determine cardinality between two vectors

cardinality(x, y = NULL, verbose = FALSE, ...)

Examples

a <- letters[c(1, 1, 2, 2, 2, 3)];
b <- LETTERS[c(1, 2, 3, 4, 5, 6)];
d <- LETTERS[c(1, 2, 2, 1, 1, 1)];

cardinality(a, b)
#> from   to 
#>    1    3 
cardinality(b, a)
#> from   to 
#>    3    1 

ab <- data.frame(a, b)
ad <- data.frame(a, d)
cardinality(ab, ad)
#> from   to 
#>    2    1 

abt <- tibble::tibble(a, b);
adt <- tibble::tibble(a, d);
cardinality(abt, adt)
#> from   to 
#>    2    1 

abm <- as.matrix(abt);
adm <- as.matrix(adt);
cardinality(abm, adm)
#> from   to 
#>    2    1 

cardinality(d, adm, verbose=TRUE)
#> ##  (12:31:33) 21Sep2023:   cardinality(): Converting y to vector with pasteByRow() 
#> from   to 
#>    1    3 

cardinality(d, adm, verbose=2)
#> ##  (12:31:33) 21Sep2023:   cardinality(): Converting y to vector with pasteByRow() 
#> ##  (12:31:33) 21Sep2023:   cardinality(): head(x, 20): 
#>   x   y
#> 1 A a_A
#> 2 B a_B
#> 3 B b_B
#> 4 A b_A
#> 5 A b_A
#> 6 A c_A
#> ##  (12:31:33) 21Sep2023:   cardinality(): head(unique(x), 20): 
#>   x   y
#> 1 A a_A
#> 2 B a_B
#> 3 B b_B
#> 4 A b_A
#> 6 A c_A
#> from   to 
#>    1    3