Extract.psp | R Documentation |
Extract a subset of a line segment pattern.
## S3 method for class 'psp'
x[i, j, drop, ..., fragments=TRUE]
x |
A two-dimensional line segment pattern.
An object of class |
i |
Subset index. Either a valid subset index in the usual R sense,
indicating which segments should be retained, or a window
(an object of class |
j |
Redundant - included for backward compatibility. |
drop |
Ignored. Required for compatibility with generic function. |
... |
Ignored. |
fragments |
Logical value indicating whether to retain all pieces of line segments
that intersect the new window ( |
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, by default, be clipped so that they lie entirely inside the window;
but if fragments=FALSE
, such segments will be removed.
Both “thinning” and “trimming” can be performed together.
A line segment pattern (of class "psp"
).
.
psp.object
,
owin.object
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", lwd=2)
plot(w, add=TRUE)
u <- a[w, fragments=FALSE]
plot(u, add=TRUE, col="blue", lwd=3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.