| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/gower.R |
| 3 |
\name{gower_dist} |
| 4 |
\alias{gower_dist} |
| 5 |
\title{Gower's distance} |
| 6 |
\usage{ |
| 7 |
gower_dist( |
| 8 |
x, |
| 9 |
y, |
| 10 |
pair_x = NULL, |
| 11 |
pair_y = NULL, |
| 12 |
eps = 1e-08, |
| 13 |
weights = NULL, |
| 14 |
ignore_case = FALSE, |
| 15 |
nthread = getOption("gd_num_thread") |
| 16 |
) |
| 17 |
} |
| 18 |
\arguments{ |
| 19 |
\item{x}{\code{[data.frame]}} |
| 20 |
|
| 21 |
\item{y}{\code{[data.frame]}} |
| 22 |
|
| 23 |
\item{pair_x}{\code{[numeric|character] (optional)} Columns in \code{x} used for comparison. |
| 24 |
See Details below.} |
| 25 |
|
| 26 |
\item{pair_y}{\code{[numeric|character] (optional)} Columns in \code{y} used for comparison. |
| 27 |
See Details below.} |
| 28 |
|
| 29 |
\item{eps}{\code{[numeric] (optional)} Computed numbers (variable ranges) |
| 30 |
smaller than \code{eps} are treated as zero.} |
| 31 |
|
| 32 |
\item{weights}{\code{[numeric] (optional)} A vector of weights of length \code{ncol(x)} |
| 33 |
that defines the weight applied to each component of the gower distance.} |
| 34 |
|
| 35 |
\item{ignore_case}{\code{[logical]} Toggle ignore case when neither \code{pair_x} |
| 36 |
nor \code{pair_y} are user-defined.} |
| 37 |
|
| 38 |
\item{nthread}{Number of threads to use for parallelization. By default, |
| 39 |
for a dual-core machine, 2 threads are used. For any other machine |
| 40 |
n-1 cores are used so your machine doesn't freeze during a big computation. |
| 41 |
The maximum nr of threads are determined using \code{omp_get_max_threads} at C level.} |
| 42 |
} |
| 43 |
\value{ |
| 44 |
A \code{numeric} vector of length \code{max(nrow(x),nrow(y))}. |
| 45 |
When there are no columns to compare, a message is printed and both |
| 46 |
\code{numeric(0)} is returned invisibly. |
| 47 |
} |
| 48 |
\description{ |
| 49 |
Compute Gower's distance, pairwise between records in two data sets \code{x} |
| 50 |
and \code{y}. Records from the smallest data set are recycled over. |
| 51 |
} |
| 52 |
\section{Details}{ |
| 53 |
|
| 54 |
There are three ways to specify which columns of \code{x} should be compared |
| 55 |
with what columns of \code{y}. The first option is do give no specification. |
| 56 |
In that case columns with matching names will be used. The second option |
| 57 |
is to use only the \code{pairs_y} argument, specifying for each column in \code{x} |
| 58 |
in order, which column in \code{y} must be used to pair it with (use \code{0} |
| 59 |
to skip a column in \code{x}). The third option is to explicitly specify the |
| 60 |
columns to be matched using \code{pair_x} and \code{pair_y}. |
| 61 |
} |
| 62 |
|
| 63 |
\section{Note}{ |
| 64 |
|
| 65 |
Gower (1971) originally defined a similarity measure (\eqn{s}, say) |
| 66 |
with values ranging from 0 (completely dissimilar) to 1 (completely similar). |
| 67 |
The distance returned here equals \eqn{1-s}. |
| 68 |
} |
| 69 |
|
| 70 |
\references{ |
| 71 |
Gower, John C. "A general coefficient of similarity and some of its |
| 72 |
properties." Biometrics (1971): 857-871. |
| 73 |
} |
| 74 |
\seealso{ |
| 75 |
\code{\link{gower_topn}} |
| 76 |
} |