The R Project SVN R

Rev

Rev 27474 | Rev 29399 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 27474 Rev 27894
Line 1... Line 1...
1
\name{dist}
1
\name{dist}
2
\title{Distance Matrix Computation}
2
\title{Distance Matrix Computation}
3
\usage{
3
\usage{
4
dist(x, method = "euclidean", diag = FALSE, upper = FALSE)
4
dist(x, method = "euclidean", diag = FALSE, upper = FALSE, p = 2)
5
 
5
 
6
as.dist(m, diag = FALSE, upper = FALSE)
6
as.dist(m, diag = FALSE, upper = FALSE)
7
 
7
 
8
\method{print}{dist}(x, diag = NULL, upper = NULL,
8
\method{print}{dist}(x, diag = NULL, upper = NULL,
9
      digits = getOption("digits"), justify = "none", right = TRUE, \dots)
9
      digits = getOption("digits"), justify = "none", right = TRUE, \dots)
Line 19... Line 19...
19
\alias{as.dist}
19
\alias{as.dist}
20
\arguments{
20
\arguments{
21
  \item{x}{a numeric matrix, data frame or \code{"dist"} object.}
21
  \item{x}{a numeric matrix, data frame or \code{"dist"} object.}
22
  \item{method}{the distance measure to be used. This must be one of
22
  \item{method}{the distance measure to be used. This must be one of
23
    \code{"euclidean"}, \code{"maximum"}, \code{"manhattan"},
23
    \code{"euclidean"}, \code{"maximum"}, \code{"manhattan"},
24
    \code{"canberra"} or \code{"binary"}.
24
    \code{"canberra"}, \code{"binary"} or \code{"minkowski"}.
25
    Any unambiguous substring can be given.}
25
    Any unambiguous substring can be given.}
26
  \item{diag}{logical value indicating whether the diagonal of the
26
  \item{diag}{logical value indicating whether the diagonal of the
27
    distance matrix should be printed by \code{print.dist}.}
27
    distance matrix should be printed by \code{print.dist}.}
28
  \item{upper}{logical value indicating whether the upper triangle of the
28
  \item{upper}{logical value indicating whether the upper triangle of the
29
    distance matrix should be printed by \code{print.dist}.}
29
    distance matrix should be printed by \code{print.dist}.}
-
 
30
  \item{p}{The power of the Minikowski distance.}
30
  \item{m}{A matrix of distances to be converted to a \code{"dist"}
31
  \item{m}{A matrix of distances to be converted to a \code{"dist"}
31
    object (only the lower triangle is used, the rest is ignored).}
32
    object (only the lower triangle is used, the rest is ignored).}
32
  \item{digits, justify}{passed to \code{\link{format}} inside of
33
  \item{digits, justify}{passed to \code{\link{format}} inside of
33
    \code{print()}.}
34
    \code{print()}.}
34
  \item{right, \dots}{further arguments, passed to the (next)
35
  \item{right, \dots}{further arguments, passed to the (next)
Line 61... Line 62...
61
    \item{\code{binary}:}{(aka \emph{asymmetric binary}): The vectors
62
    \item{\code{binary}:}{(aka \emph{asymmetric binary}): The vectors
62
      are regarded as binary bits, so non-zero elements are \sQuote{on}
63
      are regarded as binary bits, so non-zero elements are \sQuote{on}
63
      and zero elements are \sQuote{off}.  The distance is the
64
      and zero elements are \sQuote{off}.  The distance is the
64
      \emph{proportion} of bits in which only one is on amongst those in
65
      \emph{proportion} of bits in which only one is on amongst those in
65
      which at least one is on.}
66
      which at least one is on.}
-
 
67
 
-
 
68
    \item{\code{minkowki}:}{The \eqn{p} norm, the \eqn{p}th root of the
-
 
69
      sum of the \eqn{p}th powers of the differences of the components.}
66
  }
70
  }
67
 
71
 
68
  Missing values are allowed, and are excluded from all computations
72
  Missing values are allowed, and are excluded from all computations
69
  involving the rows within which they occur.
73
  involving the rows within which they occur.
70
  Further, when \code{Inf} values are involved, all pairs of values are
74
  Further, when \code{Inf} values are involved, all pairs of values are
71
  excluded when their contribution to the distance gave \code{NaN} or
75
  excluded when their contribution to the distance gave \code{NaN} or
72
  \code{NA}.\cr
76
  \code{NA}.\cr
73
  If some columns are excluded in calculating a Euclidean, Manhattan or
77
  If some columns are excluded in calculating a Euclidean, Manhattan,
74
  Canberra distance, the sum is scaled up proportionally to the number
78
  Canberra or Minkowski distance, the sum is scaled up proportionally
75
  of columns used.  If all pairs are excluded when calculating a
79
  to the number of columns used.  If all pairs are excluded when calculating a
76
  particular distance, the value is \code{NA}.
80
  particular distance, the value is \code{NA}.
77
 
81
 
78
  The functions \code{as.matrix.dist()} and \code{as.dist()} can be used
82
  The functions \code{as.matrix.dist()} and \code{as.dist()} can be used
79
  for conversion between objects of class \code{"dist"} and conventional
83
  for conversion between objects of class \code{"dist"} and conventional
80
  distance matrices and vice versa.
84
  distance matrices and vice versa.
Line 106... Line 110...
106
  Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
110
  Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
107
  \emph{The New S Language}.
111
  \emph{The New S Language}.
108
  Wadsworth \& Brooks/Cole.
112
  Wadsworth \& Brooks/Cole.
109
 
113
 
110
  Mardia, K. V., Kent, J. T. and Bibby, J. M. (1979)
114
  Mardia, K. V., Kent, J. T. and Bibby, J. M. (1979)
111
  \emph{Multivariate Analysis.} London: Academic Press.
115
  \emph{Multivariate Analysis.} Academic Press.
-
 
116
 
-
 
117
  Borg, I. and Groenen, P. (1997)
-
 
118
  \emph{Modern Multidimensional Scaling.  Theory and Applications.}
-
 
119
  Springer.
112
}
120
}
113
\seealso{
121
\seealso{
114
  \code{\link[cluster]{daisy}} in the \pkg{cluster} package with more
122
  \code{\link[cluster]{daisy}} in the \pkg{cluster} package with more
115
  possibilities in the case of \emph{mixed} (contiuous / categorical)
123
  possibilities in the case of \emph{mixed} (contiuous / categorical)
116
  variables.
124
  variables.