Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

closepaircounts

Count Close Pairs of Points


Description

Low-level functions to count the number of close pairs of points.

Usage

closepaircounts(X, r)

crosspaircounts(X, Y, r)

Arguments

X,Y

Point patterns (objects of class "ppp").

r

Maximum distance between pairs of points to be counted as close pairs.

Details

These are the efficient low-level functions used by spatstat to count close pairs of points in a point pattern or between two point patterns.

closepaircounts(X,r) counts the number of neighbours for each point in the pattern X. That is, for each point X[i], it counts the number of other points X[j] with j != i such that d(X[i],X[j]) <= r where d denotes Euclidean distance. The result is an integer vector v such that v[i] is the number of neighbours of X[i].

crosspaircounts(X,Y,r) counts, for each point in the pattern X, the number of neighbours in the pattern Y. That is, for each point X[i], it counts the number of points Y[j] such that d(X[i],X[j]) <= r. The result is an integer vector v such that v[i] is the number of neighbours of X[i] in the pattern Y.

Value

An integer vector of length equal to the number of points in X.

Warning about accuracy

The results of these functions may not agree exactly with the correct answer (as calculated by a human) and may not be consistent between different computers and different installations of R. The discrepancies arise in marginal cases where the interpoint distance is equal to, or very close to, the threshold rmax.

Floating-point numbers in a computer are not mathematical Real Numbers: they are approximations using finite-precision binary arithmetic. The approximation is accurate to a tolerance of about .Machine$double.eps.

If the true interpoint distance d and the threshold rmax are equal, or if their difference is no more than .Machine$double.eps, the result may be incorrect.

Author(s)

See Also

closepairs to identify all close pairs of points.

Examples

a <- closepaircounts(cells, 0.1)
   sum(a)
   Y <- split(amacrine)
   b <- crosspaircounts(Y$on, Y$off, 0.1)

spatstat.core

Core Functionality of the 'spatstat' Family

v2.1-2
GPL (>= 2)
Authors
Adrian Baddeley [aut, cre], Rolf Turner [aut], Ege Rubak [aut], Kasper Klitgaard Berthelsen [ctb], Achmad Choiruddin [ctb], Jean-Francois Coeurjolly [ctb], Ottmar Cronie [ctb], Tilman Davies [ctb], Julian Gilbey [ctb], Yongtao Guan [ctb], Ute Hahn [ctb], Kassel Hingee [ctb], Abdollah Jalilian [ctb], Marie-Colette van Lieshout [ctb], Greg McSwiggan [ctb], Tuomas Rajala [ctb], Suman Rakshit [ctb], Dominic Schuhmacher [ctb], Rasmus Plenge Waagepetersen [ctb], Hangsheng Wang [ctb]
Initial release
2021-04-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.