by.ppp: Apply a Function to a Point Pattern Broken Down by Factor

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/by.ppp.R

Description

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

Usage

1
2
 ## 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

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

and \rolf

See Also

ppp, split.ppp, cut.ppp, tess, im.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
  # multitype point pattern, broken down by type
  data(amacrine)
  by(amacrine, FUN=density)
  by(amacrine, FUN=function(x) { min(nndist(x)) } )

  # 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, 5, 5)
  B <- by(swedishpines, tes, clarkevans, correction="Donnelly")
  unlist(lapply(B, as.numeric))

spatstat documentation built on May 30, 2017, 7:53 a.m.

Search within the spatstat package
Search all R packages, documentation and source code