
Last chance! 50% off unlimited learning
Sale ends in
"ppp"
)
for use by the as.ppp(X, ..., fatal=TRUE)
as.ppp(X, W, ..., fatal=TRUE)
X
does not contain a window"ppp"
(see ppp.object
)
describing the point pattern and its window of observation.
The value NULL
may also be returned; see Details.spp
objects
is changed in future versions of the spatial
library,
then as.ppp
may not be able to interpret them.
It currently handles all versions of spatial
up to 7.1-4.X
to a point pattern
(an object of class "ppp"
; see ppp.object
for
an overview). This function is normally used to convert an existing point pattern
dataset, stored in another format, to the "ppp"
format.
To create a new point pattern from raw data such as $x,y$
coordinates, it is normally easier to use the creator function
ppp
.
The dataset X
may be:
"ppp"
"spp"
as defined in thespatial
library"quad"
representing a quadrature scheme
(seequad.object
)x
,y
which are numeric vectors
of equal lengthW
which is converted to a window object
by the function as.owin
.
In the first three cases, W
will be ignored. If X
is a three-column matrix or data frame, the third column
will be interpreted as containing marks, and the result will be a
marked point pattern.
The argument fatal
indicates what to do when
W
is missing and X
contains no
information about the window. If fatal=TRUE
, a fatal error
will be generated; if fatal=FALSE
, the
value NULL
is returned.
An spp
object is the representation of a point pattern
in the spatial
library. Our implementation recognises
the following formats:
x
,y
xl
,xu
,yl
,yu
x
,y
andarea
,
wherearea
is a structure with entriesxl
,xu
,yl
,yu
spatial
versions 1 to 6 and version 7.1 respectively)
where x
and y
are vectors of equal length
giving the point coordinates, and xl
, xu
, yl
,
yu
are numbers giving the dimensions of a rectangular window. The function as.ppp
is generic, with methods for the
classes "ppp"
, "quad"
, "matrix"
and a default method.
Point pattern datasets can also be created by the function
ppp
.
ppp
,
ppp.object
,
as.owin
,
owin.object
plot(c(0,1),c(0,1),type="n")
xy <- locator(20) # click on 20 points in plot window
pp <- as.ppp(xy, c(0,1,0,1))
w <- owin(c(0,1),c(0,1))
plot(w) # neater
xy <- locator(20) # click on 20 points in plot window
pp <- as.ppp(xy, w)
xy <- matrix(runif(40), ncol=2)
pp <- as.ppp(xy, c(0,1,0,1))
# Venables-Ripley format
require(spatial)
towns <- ppinit("towns.dat")
pp <- as.ppp(towns) # converted to our format
detach(package:spatial)
Run the code above in your browser using DataLab