pairwise | R Documentation |
Computes pairwise similarities/distances between two collections of objects (strings, vectors, etc.) using the provided comparator.
pairwise(comparator, x, y, return_matrix = FALSE, ...) ## S4 method for signature 'Comparator,ANY,missing' pairwise(comparator, x, y, return_matrix = FALSE, ...) ## S4 method for signature 'CppSeqComparator,list,list' pairwise(comparator, x, y, return_matrix = FALSE, ...) ## S4 method for signature 'CppSeqComparator,list,'NULL'' pairwise(comparator, x, y, return_matrix = FALSE, ...) ## S4 method for signature 'StringComparator,vector,vector' pairwise(comparator, x, y, return_matrix = FALSE, ...) ## S4 method for signature 'StringComparator,vector,'NULL'' pairwise(comparator, x, y, return_matrix = FALSE, ...) ## S4 method for signature 'NumericComparator,matrix,vector' pairwise(comparator, x, y, return_matrix = FALSE, ...) ## S4 method for signature 'NumericComparator,vector,matrix' pairwise(comparator, x, y, return_matrix = FALSE, ...) ## S4 method for signature 'Chebyshev,matrix,matrix' pairwise(comparator, x, y, return_matrix = FALSE, ...) ## S4 method for signature 'Chebyshev,matrix,'NULL'' pairwise(comparator, x, y, return_matrix = FALSE, ...) ## S4 method for signature 'Minkowski,matrix,matrix' elementwise(comparator, x, y, ...) ## S4 method for signature 'Minkowski,matrix,matrix' pairwise(comparator, x, y, return_matrix = FALSE, ...) ## S4 method for signature 'Minkowski,matrix,'NULL'' pairwise(comparator, x, y, return_matrix = FALSE, ...) ## S4 method for signature 'FuzzyTokenSet,list,list' pairwise(comparator, x, y, return_matrix = FALSE, ...) ## S4 method for signature 'FuzzyTokenSet,vector,'NULL'' pairwise(comparator, x, y, return_matrix = FALSE, ...) ## S4 method for signature 'InVocabulary,vector,vector' pairwise(comparator, x, y, return_matrix = FALSE, ...) ## S4 method for signature 'InVocabulary,vector,'NULL'' pairwise(comparator, x, y, return_matrix = FALSE, ...) ## S4 method for signature 'Lookup,vector,vector' pairwise(comparator, x, y, return_matrix = FALSE, ...) ## S4 method for signature 'Lookup,vector,'NULL'' pairwise(comparator, x, y, return_matrix = FALSE, ...) ## S4 method for signature 'MongeElkan,list,list' pairwise(comparator, x, y, return_matrix = FALSE, ...) ## S4 method for signature 'MongeElkan,list,'NULL'' pairwise(comparator, x, y, return_matrix = FALSE, ...)
comparator |
a comparator used to compare the objects, which is a
sub-class of |
x, y |
a collection of objects to compare, typically stored as entries
in an atomic vector, rows in a matrix, or entries in a list. The required
format depends on the type of |
return_matrix |
a logical of length 1. If FALSE (default), the pairwise
similarities/distances will be returned as a |
... |
other parameters passed on to other methods. |
If both x
and y
are specified, every object in x
is compared with
every object in y
using the comparator, and the resulting scores are
returned in a size(x)
by size(y)
matrix.
If only x
is specified, then the objects in x
are compared with
themselves using the comparator, and the resulting scores are returned in a
size(x)
by size(y)
matrix.
By default, the matrix is represented as an instance of the
PairwiseMatrix
class, which is more space-efficient for symmetric
comparators when y
is not specified. However, if return_matrix = TRUE
,
the matrix is returned as an ordinary matrix
instead.
comparator = Comparator,x = ANY,y = missing
: Compute a pairwise comparator when y
comparator = CppSeqComparator,x = list,y = list
: Specialization for CppSeqComparator
where x
and y
are lists of sequences (vectors) to compare.
comparator = CppSeqComparator,x = list,y = NULL
: Specialization for CppSeqComparator
where x
is
a list of sequences (vectors) to compare.
comparator = StringComparator,x = vector,y = vector
: Specialization for StringComparator
where x
and y
are vectors of strings to compare.
comparator = StringComparator,x = vector,y = NULL
: Specialization for StringComparator
where x
is a vector of strings to compare.
comparator = NumericComparator,x = matrix,y = vector
: Specialization for NumericComparator
where x
is a matrix of rows (interpreted as vectors) to compare with a vector y
.
comparator = NumericComparator,x = vector,y = matrix
: Specialization for NumericComparator
where x
is a vector to compare with a matrix y
of rows (interpreted as vectors).
comparator = Chebyshev,x = matrix,y = matrix
: Specialization for Chebyshev
where x
and y
matrices of rows (interpreted as vectors) to compare.
comparator = Chebyshev,x = matrix,y = NULL
: Specialization for Minkowski
where x
is a matrix
of rows (interpreted as vectors) to compare among themselves.
comparator = Minkowski,x = matrix,y = matrix
: Specialization for a Minkowski
where x
and y
matrices of rows (interpreted as vectors) to compare.
comparator = Minkowski,x = matrix,y = matrix
: Specialization for a Minkowski
where x
and y
matrices of rows (interpreted as vectors) to compare.
comparator = Minkowski,x = matrix,y = NULL
: Specialization for Minkowski
where x
is a matrix
of rows (interpreted as vectors) to compare among themselves.
comparator = FuzzyTokenSet,x = list,y = list
: Specialization for FuzzyTokenSet
where x
and y
are
lists of token vectors to compare.
comparator = FuzzyTokenSet,x = vector,y = NULL
: Specialization for FuzzyTokenSet
where x
is a list of token
vectors to compare among themselves.
comparator = InVocabulary,x = vector,y = vector
: Specialization for InVocabulary
where x
and y
are vectors of strings to compare.
comparator = InVocabulary,x = vector,y = NULL
: Specialization for InVocabulary
where x
is a
vector of strings to compare among themselves.
comparator = Lookup,x = vector,y = vector
: Specialization for a Lookup
where x
and y
are
vectors of strings to compare
comparator = Lookup,x = vector,y = NULL
: Specialization for Lookup
where x
is a vector of
strings to compare among themselves
comparator = MongeElkan,x = list,y = list
: Specialization for MongeElkan
where x
and y
are
lists of token vectors to compare.
comparator = MongeElkan,x = list,y = NULL
: Specialization for MongeElkan
where x
is a list
of token vectors to compare among themselves.
## Computing the distances between a query point y (a 3D numeric vector) ## and a set of reference points x x <- rbind(c(1,0,1), c(0,0,0), c(-1,2,-1)) y <- c(10, 5, 10) pairwise(Manhattan(), x, y) ## Computing the pairwise similarities among a set of strings x <- c("Benjamin", "Ben", "Benny", "Bne", "Benedict", "Benson") comparator <- DamerauLevenshtein(similarity = TRUE, normalize = TRUE) pairwise(comparator, x, return_matrix = TRUE) # return an ordinary matrix
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.