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

by.ppp

Apply a Function to a Point Pattern Broken Down by Factor


Description

Splits a point pattern into sub-patterns, and applies the function to each sub-pattern.

Usage

## S3 method for class 'ppp'
by(data, INDICES=marks(data), FUN, ...)

Arguments

data

Point pattern (object of class "ppp").

INDICES

Grouping variable. Either a factor, a pixel image with factor values, or a tessellation.

FUN

Function to be applied to subsets of data.

...

Additional arguments to FUN.

Details

This is a method for the generic function by for point patterns (class "ppp").

The point pattern data is first divided into subsets according to INDICES. Then the function FUN is applied to each subset. The results of each computation are returned in a list.

The argument INDICES may be

  • a factor, of length equal to the number of points in data. The levels of INDICES determine the destination of each point in data. The ith point of data will be placed in the sub-pattern split.ppp(data)$l where l = f[i].

  • a pixel image (object of class "im") with factor values. The pixel value of INDICES at each point of data will be used as the classifying variable.

  • a tessellation (object of class "tess"). Each point of data will be classified according to the tile of the tessellation into which it falls.

If INDICES is missing, then data must be a multitype point pattern (a marked point pattern whose marks vector is a factor). Then the effect is that the points of each type are separated into different point patterns.

Value

A list (also of class "anylist" or "solist" as appropriate) containing the results returned from FUN for each of the subpatterns.

Author(s)

Adrian Baddeley Adrian.Baddeley@curtin.edu.au, Rolf Turner r.turner@auckland.ac.nz and Ege Rubak rubak@math.aau.dk.

See Also

Examples

# multitype point pattern, broken down by type
  data(amacrine)
  by(amacrine, FUN=minnndist)
  by(amacrine, FUN=function(x) { intensity(unmark(x)) })

  if(require(spatstat.core)) {
  # how to pass additional arguments to FUN
  by(amacrine, FUN=clarkevans, correction=c("Donnelly","cdf"))
  }

  # point pattern broken down by tessellation
  data(swedishpines)
  tes <- quadrats(swedishpines, 4,4)
  ## compute minimum nearest neighbour distance for points in each tile
  B <- by(swedishpines, tes, minnndist)

  if(require(spatstat.core)) {
  B <- by(swedishpines, tes, clarkevans, correction="Donnelly")
  simplify2array(B)
  }

spatstat.geom

Geometrical Functionality of the 'spatstat' Family

v2.1-0
GPL (>= 2)
Authors
Adrian Baddeley [aut, cre], Rolf Turner [aut], Ege Rubak [aut], Tilman Davies [ctb], Ute Hahn [ctb], Abdollah Jalilian [ctb], Sebastian Meyer [ctb], Suman Rakshit [ctb], Dominic Schuhmacher [ctb], Rasmus Waagepetersen [ctb]
Initial release
2021-04-15

We don't support your browser anymore

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