rshift.psp | R Documentation |
Randomly shifts the segments in a line segment pattern.
## S3 method for class 'psp'
rshift(X, ..., group=NULL, which=NULL)
X |
Line segment pattern to be subjected to a random shift.
An object of class |
... |
Arguments controlling the randomisation and the handling of edge
effects. See |
group |
Optional. Factor specifying a grouping of the line segments of |
which |
Optional. Identifies which groups of the pattern will be shifted,
while other groups are not shifted. A vector of levels of |
This operation randomly shifts the locations of the line segments in a line segment pattern.
The function rshift
is generic. This function rshift.psp
is the method for line segment patterns.
The line segments of X
are first divided into groups,
then the line segments within a group are shifted by a common
random displacement vector. Different groups of line segments are shifted
independently.
If the argument group
is present, then this determines the grouping.
Otherwise, all line segments belong to a single group.
The argument group
should be a factor, of length equal to the
number of line segments in X
.
Alternatively group
may be NULL
,
which specifies that all line segments of X
belong to a single group.
By default, every group of line segments will be shifted.
The argument which
indicates that only some of the groups
should be shifted, while other groups should be left unchanged.
which
must be a vector of levels of group
indicating which groups are to be shifted.
The displacement vector, i.e. the vector
by which the data line segments are shifted,
is generated at random.
The default behaviour is
to generate a displacement vector at random with equal probability
for all possible displacements. This means that the x
and
y
coordinates of the displacement vector are independent random
variables, uniformly distributed over the range of possible coordinates.
Alternatively, the displacement vector can be generated by
another random mechanism, controlled by the arguments
radius
, width
and height
.
if width
and height
are given, then
the displacement vector is uniformly distributed
in a rectangle of these dimensions, centred at
the origin. The maximum possible displacement in the x
direction is width/2
. The maximum possible displacement in
the y
direction is height/2
. The x
and y
displacements are independent. (If width
and height
are actually equal to the dimensions of the observation window,
then this is equivalent to the default.)
if radius
is given, then the displacement vector is
generated by choosing a random line segment inside a disc of
the given radius, centred at the origin, with uniform probability
density over the disc. Thus the argument radius
determines
the maximum possible displacement distance.
The argument radius
is incompatible with the
arguments width
and height
.
The argument edge
controls what happens when
a shifted line segment lies partially or completely
outside the window of X
. Currently the only option is
"erode"
which specifies that the segments will be clipped
to a smaller window.
The optional argument clip
specifies a smaller window
to which the pattern should be restricted.
A line segment pattern (object of class "psp"
).
and \rolf
rshift
,
rshift.ppp
X <- psp(runif(20), runif(20), runif(20), runif(20), window=owin())
Y <- rshift(X, radius=0.1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.