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

multiplicity.Spatial

Count Number of Instances of Points


Description

The generic function multiplicity defined in spatstat.geom is intended to count the number of duplicates of each element of an object. spatstat.geom already offers methods for point patterns, matrices and data frames, and here we add a method for Spatial objects from the sp package. It is a wrapper for the default method, which effectively computes the distance matrix of the points, and then just counts the number of zeroes in each row.

Usage

## S3 method for class 'Spatial'
multiplicity(x)

Arguments

x

a "Spatial" object (we only need a coordinates-method), e.g. of class "SpatialPoints".

Value

an integer vector containing the number of instances of each point of the object.

See Also

multiplicity in package spatstat.geom. See the Examples of the hagelloch data for a specific use of multiplicity.

Examples

foo <- SpatialPoints(matrix(c(1,2,
                              2,3,
                              1,2,
                              4,5), 4, 2, byrow=TRUE))
multiplicity(foo)

# the following function determines the multiplicities in a matrix
# or data frame and returns unique rows with appended multiplicity
countunique <- function(x) unique(cbind(x, count=multiplicity(x)))
countunique(coordinates(foo))

surveillance

Temporal and Spatio-Temporal Modeling and Monitoring of Epidemic Phenomena

v1.19.1
GPL-2
Authors
Michael H<f6>hle [aut, ths] (<https://orcid.org/0000-0002-0423-6702>), Sebastian Meyer [aut, cre] (<https://orcid.org/0000-0002-1791-9449>), Michaela Paul [aut], Leonhard Held [ctb, ths], Howard Burkom [ctb], Thais Correa [ctb], Mathias Hofmann [ctb], Christian Lang [ctb], Juliane Manitz [ctb], Andrea Riebler [ctb], Daniel Saban<e9>s Bov<e9> [ctb], Ma<eb>lle Salmon [ctb], Dirk Schumacher [ctb], Stefan Steiner [ctb], Mikko Virtanen [ctb], Wei Wei [ctb], Valentin Wimmer [ctb], R Core Team [ctb] (A few code segments are modified versions of code from base R)
Initial release
2021-03-30

We don't support your browser anymore

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