# as.ppp

##### Convert Data To Class ppp

Tries to coerce any reasonable kind of data to a point pattern
(an object of class `"ppp"`

)
for use by the `spatstat`

package).

- Keywords
- spatial

##### Usage

```
as.ppp(X)
as.ppp(X, W)
as.ppp(X, fatal=TRUE)
```

##### Arguments

- X
- Data which will be converted into a point pattern
- W
- Data which define a default window for the pattern
- fatal
- Logical value. See Details.

##### Details

This function tries to coerce the data `X`

to a point pattern
(an object of class `"ppp"`

; see `ppp.object`

for
an overview). The optional argument `W`

is a default window for the
pattern; it is used only if a window is not specified in `X`

.

The data `X`

may be:

- an object of class
`"ppp"`

- an object of class
`"spp"`

as defined in the`spatial`

library - an object of class
`"quad"`

representing a quadrature scheme (see`quad.object`

) - a two-column matrix
- a structure with entries
`x`

,`y`

`W`

which is converted to a window object
by the function `as.owin`

.
In the first three cases, `W`

will be ignored. 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:

- a structure with entries
`x`

,`y`

`xl`

,`xu`

,`yl`

,`yu`

- a structure with entries
`x`

,`y`

and`area`

, where`area`

is a structure with entries`xl`

,`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. Point pattern datasets can also be created by the function
`ppp`

.

##### Value

- An object of class
`"ppp"`

(see`ppp.object`

) describing the point pattern and its window of observation. The value`NULL`

may also be returned; see Details.

##### synopsis

as.ppp(X, W=NULL, fatal=TRUE)

##### Warnings

If the format of `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.

##### See Also

##### Examples

```
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)
```

*Documentation reproduced from package spatstat, version 1.5-9, License: GPL version 2 or newer*