Match list elements to another list
Value
integer vector with the same length as x. The
integer values give the position in y of the first match.
Details
This function takes two list objects, and matches
the first list elements to the second list.
Each list contains list elements, for example if x
is a list, then the element in position i is accessed
using x[[i]].
A match between x[[i]] and y[[j]] is defined as follows:
- all elements in - x[[i]]are contained in- y[[j]]
- all elements in - y[[j]]are contained in- x[[i]]
For this function, item order and item duplication is ignored.
This function uses logic in the form all(x[[i]] %in% y[[j]]),
so it will operate properly with input objects compatible
with that format. The function is intended to be used with
list that contains atomic vectors.
See also
Other venndir internal:
assemble_venndir_label(),
assign_degree_groups(),
check_systemfonts_family(),
expand_range(),
get_venn_polygon_shapes(),
make_degrees_clockwise(),
make_venn_combn_df(),
print_color_df(),
render_venndir_footnotes(),
shrink_df(),
simple_ellipse(),
subset_systemfonts(),
venndir_label_style(),
venndir_to_df()
Examples
x <- list(a=LETTERS[1],
   b=LETTERS[1:2],
   c=LETTERS[2:4]);
x;
#> $a
#> [1] "A"
#> 
#> $b
#> [1] "A" "B"
#> 
#> $c
#> [1] "B" "C" "D"
#> 
y <- list(
   d=LETTERS[1:2],
   e=LETTERS[2],
   f=LETTERS[2:4]);
y;
#> $d
#> [1] "A" "B"
#> 
#> $e
#> [1] "B"
#> 
#> $f
#> [1] "B" "C" "D"
#> 
match_list(x, y)
#>  a  b  c 
#> NA  1  3 
match_list(y, x)
#>  d  e  f 
#>  2 NA  3