compare.vectors: Compare all combinations of vectors using set operations

Description Usage Arguments Value Examples

Description

Compare all combinations of vectors using set operations

Usage

1
2
3
4
5
6
7
8
compare.vectors(named_list_of_vectors_to_compare,
  degrees_of_comparison_to_include = NULL, draw_venn_diagrams = FALSE,
  vector_colors_for_venn_diagrams = NULL, save_venn_diagram_files = FALSE,
  location_for_venn_diagram_files = "", prefix_for_venn_diagram_files = "",
  saved_venn_diagram_resolution_ppi = 300,
  saved_venn_diagram_dimension_units = "in", saved_venn_diagram_width = 8,
  saved_venn_diagram_height = 6, viewport_npc_width_height_for_images = 1,
  suppress_messages = FALSE)

Arguments

named_list_of_vectors_to_compare

A named list of vectors to compare (see, for example, example.vectors.list). Duplicate values in a given vector will only be counted once (for example, c("a", "a", "b", "c") will be treated identically to c("a", "b", "c").

degrees_of_comparison_to_include

A number or vector of numbers of which degrees of comparison to print (for example, 'c(2, 5)' would print only 2- and 5-way vector comparisons).

draw_venn_diagrams

A logical (TRUE/FALSE) indicator whether to draw Venn diagrams for all 2- through 5-way comparisons of vectors.

vector_colors_for_venn_diagrams

An optional vector of color names for Venn diagrams (if draw_venn_diagrams is TRUE). Color names are applied to the named vectors in named_list_of_vectors_to_compare in their order in named_list_of_vectors_to_compare. If this is blank, a random color will be selected for each vector. Either way, each vector will have a consistent color across the Venn diagrams in which it appears.

save_venn_diagram_files

A logical (TRUE/FALSE) indicator whether to save Venn diagrams as PNG files.

location_for_venn_diagram_files

An optional string giving a directory into which to save Venn diagram PNG files (if save_venn_diagram_files is TRUE). This location must already exist on the filesystem.

prefix_for_venn_diagram_files

An optional string giving a prefix to prepend to saved Venn diagram PNG files (if save_venn_diagram_files is TRUE).

saved_venn_diagram_resolution_ppi

An optional number giving a resolution (PPI) for saved Venn diagrams (if save_venn_diagram_files is TRUE).

saved_venn_diagram_dimension_units

An optional string giving units for specifying saved_venn_diagram_width and saved_venn_diagram_height (if save_venn_diagram_files is TRUE). Can be px (pixels), in (inches, the default), cm, or mm.

saved_venn_diagram_width

The width (in saved_venn_diagram_dimension_units units) for saved Venn diagrams (if save_venn_diagram_files is TRUE).

saved_venn_diagram_height

The height (in saved_venn_diagram_dimension_units units) for saved Venn diagrams (if save_venn_diagram_files is TRUE).

viewport_npc_width_height_for_images

The scale at which to print an image. If the image is cut off at its edges, for example, this can be set lower than 1.0.

suppress_messages

A logical (TRUE/FALSE) indicator whether to suppress messages. Even if this is TRUE, warnings will still be printed.

Value

A list, with one object for each comparison of vectors. The list contains the following elements:

elements_involved

The vector names involved in the comparison.

union_of_elements

A vector of all (deduplicated) items involved in the comparison, across all of the vectors.

overlap_of_elements

A vector of the deduplicated elements that occurred in all of the compared vectors.

elements_unique_to_first_element

This element will have a sub-element named for each vector being compared (i.e., for each of the names in $elements_involved). The (deduplicated) items that were unique to that vector (i.e., not overlapping with any other vector in the comparison).

venn_diagram

If save_venn_diagram_files is TRUE, and the comparison is of 2 through 5 vectors, a Venn diagram object produced using the VennDiagram package. This diagram can be rendered using render.venn.diagram.

To compile this list object into a Markdown report, use compare.vectors.and.return.text.analysis.of.overlap. For an example of this usage, see the Veccompare Overlap Report RMarkdown template for RStudio that is installed as part of the veccompare package.

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
example <- veccompare::compare.vectors(veccompare::example.vectors.list)

# To extract similar elements across list items:
veccompare::extract.compared.vectors(
  example,
  elements_of_output = "elements_involved"
)

# To extract all comparisons that involve "vector_a":
veccompare::extract.compared.vectors(
  example,
  vector_names = "vector_a"
)

# To find all comparisons that were about "vector_a" and "vector_c":
veccompare::extract.compared.vectors(
  example,
  vector_names = c("vector_a", "vector_c"),
  only_match_vector_names = TRUE
)

# To get all elements that did a two-way comparison:
veccompare::extract.compared.vectors(
  example,
  degrees_of_comparison = 2
)

publicus/r-veccompare documentation built on May 10, 2019, 1:18 p.m.