Learn R Programming

spatstat (version 1.11-4)

subset.psp: Extract Subset of Line Segment Pattern

Description

Extract a subset of a line segment pattern.

Usage

## S3 method for class 'psp':
[(x, i, j, drop, ...)

Arguments

x
A two-dimensional line segment pattern. An object of class "psp".
i
Subset index. Either a valid subset index in the usual Rsense, indicating which segments should be retained, or a window (an object of class "owin") delineating a subset of the original observation window.
j
Redundant - included for backward compatibility.
drop
Ignored. Required for compatibility with generic function.
...
Ignored.

Value

  • A line segment pattern (of class "psp").

Details

These functions extract a designated subset of a line segment pattern.

The function [.psp is a method for [ for the class "psp". It extracts a designated subset of a line segment pattern, either by ``thinning'' (retaining/deleting some line segments of a line segment pattern) or ``trimming'' (reducing the window of observation to a smaller subregion and clipping the line segments to this boundary) or both. The pattern will be ``thinned'' if subset is specified. The line segments designated by subset will be retained. Here subset can be a numeric vector of positive indices (identifying the line segments to be retained), a numeric vector of negative indices (identifying the line segments to be deleted) or a logical vector of length equal to the number of line segments in the line segment pattern x. In the latter case, the line segments for which subset[i]=TRUE will be retained, and the others will be deleted. The pattern will be ``trimmed'' if window is specified. This should be an object of class owin specifying a window of observation to which the line segment pattern x will be trimmed. Line segments of x lying inside the new window will be retained unchanged. Line segments lying partially inside the new window and partially outside it will be clipped so that they lie entirely inside. Both ``thinning'' and ``trimming'' can be performed together.

See Also

psp.object, owin.object

Examples

Run this code
a <- psp(runif(20),runif(20),runif(20),runif(20), window=owin())
    plot(a)
  # thinning
    id <- sample(c(TRUE, FALSE), 20, replace=TRUE)
    b <- a[id]
    plot(b, add=TRUE, lwd=3)
 # trimming
    plot(a)
    w <- owin(c(0.1,0.7), c(0.2, 0.8))
    b <- a[,w]
    plot(b, add=TRUE, col="red")

Run the code above in your browser using DataLab