extract.compared.vectors: Extract elements from the output of 'compare.vectors'

Description Usage Arguments Value Examples

Description

Straightforwardly extract particular elements from the output of compare.vectors.

Usage

1
2
3
extract.compared.vectors(output_from_compare.vectors, vector_names = NULL,
  only_match_vector_names = FALSE, degrees_of_comparison = NULL,
  elements_of_output = NULL)

Arguments

output_from_compare.vectors

The list output of compare.vectors.

vector_names

An optional vector of names to extract from the named list (named_list_of_vectors_to_compare) used with compare.vectors.

only_match_vector_names

A logical (TRUE/FALSE) indicator whether to match only vector_names. If vector_names is c("a", "b"), for example, and only_match_vector_names is TRUE, this function will output only the comparison between a and b. If only_match_vector_names is FALSE, however, this function will output the comparison between a and b, as well as between a, b, and c, etc.

degrees_of_comparison

An optional number of vector of numbers indicating which degrees of comparison to return (for example, 2 will return only two-way comparisons from output_from_compare.vectors.

elements_of_output

An optional vector of element names from output_from_compare.vectors to return (for example, "elements_involved"). See the Value section of compare.vectors for a list of the elements to choose from.

Value

A winnowed version of output_from_compare.vectors. Depending on arguments, either a list, a vector, or a string.

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
27
28
29
30
31
32
33
34
35
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
)

# A more complex / specific example:
extract.compared.vectors(
  example,
  vector_names = c("vector_a", "vector_c"),
  only_match_vector_names = FALSE,
  degrees_of_comparison = c(2, 3),
  elements_of_output = "elements_involved"
)

veccompare documentation built on May 2, 2019, 7:29 a.m.