| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/gower.R |
| 3 |
\name{gower_topn} |
| 4 |
\alias{gower_topn} |
| 5 |
\title{Find the top-n matches} |
| 6 |
\usage{ |
| 7 |
gower_topn( |
| 8 |
x, |
| 9 |
y, |
| 10 |
pair_x = NULL, |
| 11 |
pair_y = NULL, |
| 12 |
n = 5, |
| 13 |
eps = 1e-08, |
| 14 |
weights = NULL, |
| 15 |
ignore_case = FALSE, |
| 16 |
nthread = getOption("gd_num_thread") |
| 17 |
) |
| 18 |
} |
| 19 |
\arguments{ |
| 20 |
\item{x}{\code{[data.frame]}} |
| 21 |
|
| 22 |
\item{y}{\code{[data.frame]}} |
| 23 |
|
| 24 |
\item{pair_x}{\code{[numeric|character] (optional)} Columns in \code{x} used for comparison. |
| 25 |
See Details below.} |
| 26 |
|
| 27 |
\item{pair_y}{\code{[numeric|character] (optional)} Columns in \code{y} used for comparison. |
| 28 |
See Details below.} |
| 29 |
|
| 30 |
\item{n}{The top-n indices and distances to return.} |
| 31 |
|
| 32 |
\item{eps}{\code{[numeric] (optional)} Computed numbers (variable ranges) |
| 33 |
smaller than \code{eps} are treated as zero.} |
| 34 |
|
| 35 |
\item{weights}{\code{[numeric] (optional)} A vector of weights of length \code{ncol(x)} |
| 36 |
that defines the weight applied to each component of the gower distance.} |
| 37 |
|
| 38 |
\item{ignore_case}{\code{[logical]} Toggle ignore case when neither \code{pair_x} |
| 39 |
nor \code{pair_y} are user-defined.} |
| 40 |
|
| 41 |
\item{nthread}{Number of threads to use for parallelization. By default, |
| 42 |
for a dual-core machine, 2 threads are used. For any other machine |
| 43 |
n-1 cores are used so your machine doesn't freeze during a big computation. |
| 44 |
The maximum nr of threads are determined using \code{omp_get_max_threads} at C level.} |
| 45 |
} |
| 46 |
\value{ |
| 47 |
A \code{list} with two array elements: \code{index} |
| 48 |
and \code{distance}. Both have size \code{n X nrow(x)}. Each ith column |
| 49 |
corresponds to the top-n best matches of \code{x} with rows in \code{y}. |
| 50 |
When there are no columns to compare, a message is printed and both |
| 51 |
\code{distance} and \code{index} will be empty matrices; the list is |
| 52 |
then returned invisibly. |
| 53 |
} |
| 54 |
\description{ |
| 55 |
Find the top-n matches in \code{y} for each record in \code{x}. |
| 56 |
} |
| 57 |
\examples{ |
| 58 |
# find the top 4 best matches in the iris data set with itself. |
| 59 |
x <- iris[1:3,] |
| 60 |
lookup <- iris[1:10,] |
| 61 |
gower_topn(x=x,y=lookup,n=4) |
| 62 |
|
| 63 |
|
| 64 |
} |
| 65 |
\seealso{ |
| 66 |
\code{\link{gower_dist}} |
| 67 |
} |