File: nnwhich.lpp.Rd

package info (click to toggle)
r-cran-spatstat.linnet 3.2-5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,664 kB
  • sloc: ansic: 2,107; makefile: 32; sh: 13
file content (67 lines) | stat: -rw-r--r-- 1,872 bytes parent folder | download
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
\name{nnwhich.lpp}
\alias{nnwhich.lpp}
\title{
  Identify Nearest Neighbours on a Linear Network
}
\description{
  Given a pattern of points on a linear network, identify the
  nearest neighbour for each point, measured
  by the shortest path in the network.
}
\usage{
\method{nnwhich}{lpp}(X, ..., k=1, method="C")
}
\arguments{
  \item{X}{
    Point pattern on linear network (object of class \code{"lpp"}).
  }
  \item{method}{
    Optional string determining the method of calculation.
    Either \code{"interpreted"} or \code{"C"}.
  }
  \item{k}{
    Integer, or integer vector. The algorithm will find the
    \code{k}th nearest neighbour. 
  }
  \item{\dots}{
    Ignored.
  }
}
\details{
  Given a pattern of points on a linear network,
  this function finds the nearest neighbour of each point
  (i.e. for each point it identifies the nearest other point)
  measuring distance by the shortest path in the network.
  
  If \code{method="C"} the task is performed using
  code in the C language. If \code{method="interpreted"} then the
  computation is performed using interpreted \R code. The \R code is
  much slower, but is provided for checking purposes.

  The result is \code{NA} if the \code{k}th nearest neighbour
  does not exist. This can occur
  if there are fewer than \code{k+1} points in the dataset, or if
  the linear network is not connected.
}
\value{
  An integer vector, of length equal to the number of points in
  \code{X}, identifying the nearest neighbour of each point.
  If \code{nnwhich(X)[2] = 4} then the nearest neighbour of
  point 2 is point 4.

  Alternatively a matrix with one row for each point in \code{X}
  and one column for each entry of \code{k}.
}
\author{
  \adrian
}
\seealso{
  \code{\link{lpp}}
}
\examples{
   X <- runiflpp(10, simplenet)
   nnwhich(X)
   nnwhich(X, k=2)
}
\keyword{spatial}
\concept{Linear network}