Last chance! 50% off unlimited learning
Sale ends in
superimpose(...)
## S3 method for class 'ppp':
superimpose(\dots, W=NULL, check=TRUE)
## S3 method for class 'psp':
superimpose(\dots, W=NULL, check=TRUE)
## S3 method for class 'default':
superimpose(\dots, W=NULL, check=TRUE)
"owin"
, or something
acceptable to as.owin
), or a function
which returns a window, superimpose.ppp
, a point pattern (object of class "ppp"
).
For superimpose.default
, either a point pattern
(object of class "ppp"
) or a list(x,y)
.
For superimpose.psp
, a line segment pattern (object of class
"psp"
).superimpose
is generic, with methods
for the class ppp
of point patterns, the class psp
of line segment patterns, and a default method. The dispatch to a
method is determined by the class of the first argument in ...
.
default
: If the first argument isnotan object of classppp
orpsp
, then the
default methodsuperimpose.default
is executed.
All arguments in...
must have componentsx
andy
representing spatial coordinates. They may include
objects of classppp
.
The result will be either alist(x,y)
or a point pattern (objects of classppp
)
as explained below.ppp
:
If the first...
argument is an object of
classppp
then the methodsuperimpose.ppp
is executed. All arguments in...
must be eitherppp
objects or lists
with componentsx
andy
. The result will
be an object of classppp
....
argument is an object of
classpsp
then thepsp
method is dispatched and all...
arguments must bepsp
objects.
The result is apsp
object.The patterns are not required to have the same window of observation.
The window for the superimposed pattern is controlled
by the argument W
.
W
is a window (object of class"W"
or something acceptable toas.owin
)
then this determines the window for the superimposed pattern.W
isNULL
, or the character string"none"
,
then windows are extracted from the geometric patterns,
as follows.
Forsuperimpose.psp
, all arguments...
are line segment patterns (objects of class"psp"
);
their observation windows are extracted; the union of these
windows is computed; and this union is taken to be the
window for the superimposed pattern.
Forsuperimpose.ppp
andsuperimpose.default
,
the arguments...
are inspected, and
any arguments which are point patterns (objects of class"ppp"
) are selected; their observation windows
are extracted, and the union of these windows
is taken to be the window for the superimposed point pattern.
Forsuperimpose.default
if none of the arguments
is of class"ppp"
then no window is computed
and the result ofsuperimpose
is alist(x,y)
.W
is one of the strings"convex"
,"rectangle"
or"bbox"
then a window for the superimposed pattern
is computed from the coordinates of the
points or the line segments as follows.[object Object],[object Object],[object Object]W
is a function,
then this function is used to compute
a window for the superimposed pattern
from the coordinates of the
points or the line segments.
The function should accept input of the formlist(x,y)
and is expected to return an object of class"owin"
.
Examples of such functions areripras
andbounding.box.xy
....
may be marked patterns.
The marks of each component pattern must have the same format.
Numeric and character marks may be ``mixed''. If there is such
mixing then the numeric marks are coerced to character in the
combining process. If the mark structures are all data frames,
then these data frames must have the same number of columns and
identical column names. If the arguments ...
are given in the form name=value
,
then the name
s will be used as an extra column of marks
attached to the elements of the corresponding patterns.
concatxy
, quadscheme
.# superimposing point patterns
p1 <- runifrect(30)
p2 <- runifrect(42)
s1 <- superimpose(p1,p2) # Unmarked pattern.
p3 <- list(x=rnorm(20),y=rnorm(20))
s2 <- superimpose(p3,p2,p1) # Default method gets called.
s2a <- superimpose(p1,p2,p3) # Same as s2 except for order of points.
s3 <- superimpose(clyde=p1,irving=p2) # Marked pattern; marks a factor
# with levels "clyde" and "irving";
# warning given.
marks(p1) <- factor(sample(LETTERS[1:3],30,TRUE))
marks(p2) <- factor(sample(LETTERS[1:3],42,TRUE))
s5 <- superimpose(clyde=p1,irving=p2) # Marked pattern with extra column
marks(p2) <- data.frame(a=marks(p2),b=runif(42))
s6 <- try(superimpose(p1,p2)) # Gives an error.
marks(p1) <- data.frame(a=marks(p1),b=1:30)
s7 <- superimpose(p1,p2) # O.K.
# how to make a 2-type point pattern with types "a" and "b"
u <- superimpose(a = rpoispp(10), b = rpoispp(20))
# how to make a 2-type point pattern with types 1 and 2
u <- superimpose("1" = rpoispp(10), "2" = rpoispp(20))
# superimposing line segment patterns
X <- rpoisline(10)
Y <- as.psp(matrix(runif(40), 10, 4), window=owin())
Z <- superimpose(X, Y)
# being unreasonable
crud <- superimpose(p1,p2,X,Y) # Gives an error, of course!
Run the code above in your browser using DataLab