split.ppp {spatstat.geom}R Documentation

Divide Point Pattern into Sub-patterns

Description

Divides a point pattern into several sub-patterns, according to their marks, or according to any user-specified grouping.

Usage

  ## S3 method for class 'ppp'
split(x, f = marks(x), drop=FALSE, un=NULL, reduce=FALSE, ...)
  ## S3 replacement method for class 'ppp'
split(x, f = marks(x), drop=FALSE, un=NULL, ...) <- value

Arguments

x

A two-dimensional point pattern. An object of class "ppp".

f

Data determining the grouping. Either a factor, a logical vector, a pixel image with factor values, a tessellation, a window, or the name of one of the columns of marks.

drop

Logical. Determines whether empty groups will be deleted.

un

Logical. Determines whether the resulting subpatterns will be unmarked (i.e. whether marks will be removed from the points in each subpattern).

reduce

Logical. Determines whether to delete the column of marks used to split the pattern, when the marks are a data frame.

...

Other arguments are ignored.

value

List of point patterns.

Details

The function split.ppp divides up the points of the point pattern x into several sub-patterns according to the values of f. The result is a list of point patterns.

The argument f may be

If f is missing, then it will be determined by the marks of the point pattern. The pattern x can be either

Some of the sub-patterns created by the split may be empty. If drop=TRUE, then empty sub-patterns will be deleted from the list. If drop=FALSE then they are retained.

The argument un determines how to handle marks in the case where x is a marked point pattern. If un=TRUE then the marks of the points will be discarded when they are split into groups, while if un=FALSE then the marks will be retained.

If f and un are both missing, then the default is un=TRUE for multitype point patterns and un=FALSE for marked point patterns with a data frame of marks.

If the marks of x are a data frame, then split(x, reduce=TRUE) will discard only the column of marks that was used to split the pattern. This applies only when the argument f is missing.

The result of split.ppp has class "splitppp" and can be plotted using plot.splitppp.

The assignment function split<-.ppp updates the point pattern x so that it satisfies split(x, f, drop, un) = value. The argument value is expected to be a list of point patterns, one for each level of f. These point patterns are expected to be compatible with the type of data in the original pattern x.

Splitting can also be undone by the function superimpose, but this typically changes the ordering of the data.

Value

The value of split.ppp is a list of point patterns. The components of the list are named by the levels of f. The list also has the class "splitppp".

The assignment form split<-.ppp returns the updated point pattern x.

Author(s)

Adrian Baddeley Adrian.Baddeley@curtin.edu.au, Rolf Turner rolfturner@posteo.net and Ege Rubak rubak@math.aau.dk.

See Also

cut.ppp, plot.splitppp, superimpose, im, tess, ppp.object

Examples


# (1) Splitting by marks

# Multitype point pattern: separate into types
 u <- split(amacrine)

# plot them
 plot(split(amacrine))

# the following are equivalent:
 amon <- split(amacrine)$on
 amon <- unmark(amacrine[amacrine$marks == "on"])
 amon <- subset(amacrine, marks == "on", -marks)
   
# the following are equivalent:
 amon <- split(amacrine, un=FALSE)$on
 amon <- amacrine[amacrine$marks == "on"]
   
# Scramble the locations of the 'on' cells
 X <- amacrine
 u <- split(X)
 u$on <- runifrect(npoints(amon), Window(amon))
 split(X) <- u

# Point pattern with continuous marks
 trees <- longleaf
 
 # cut the range of tree diameters into three intervals
 # using cut.ppp
 long3 <- cut(trees, breaks=3)
 # now split them
 long3split <- split(long3)

# (2) Splitting by a factor

# Unmarked point pattern
  swedishpines
# cut & split according to nearest neighbour distance
  f <- cut(nndist(swedishpines), 3)
  u <- split(swedishpines, f)

# (3) Splitting over a tessellation
   tes <- tess(xgrid=seq(0,96,length=5),ygrid=seq(0,100,length=5))
   v <- split(swedishpines, tes)


# (4) how to apply an operation to selected points:
#  split into components, transform desired component, then un-split
#  e.g. apply random jitter to 'on' points only
  X <- amacrine
  Y <- split(X)
  Y$on <- rjitter(Y$on, 0.1)
  split(X) <- Y

[Package spatstat.geom version 3.3-2 Index]