linfun {spatstat.linnet} | R Documentation |
Function on a Linear Network
Description
Create a function on a linear network.
Usage
linfun(f, L)
Arguments
f |
A |
L |
A linear network (object of class |
Details
This creates an object of class "linfun"
.
This is a simple mechanism for handling a function
defined on a linear network, to make it easier to display
and manipulate.
f
should be a function
in the R language,
with formal arguments x,y,seg,tp
(and optional additional
arguments) where x,y
are
Cartesian coordinates of locations on the linear network,
seg, tp
are the local coordinates.
The function f
should be vectorised: that is,
if x,y,seg,tp
are numeric vectors of the same length
n
, then v <- f(x,y,seg,tp)
should be a vector of length n
.
L
should be a linear network (object of class "linnet"
)
on which the function f
is well-defined.
The result is a function g
in the R language which belongs to
the special class "linfun"
. There are several methods
for this class including print
, plot
and as.linim
.
This function can be called as g(X)
where X
is an "lpp"
object,
or called as g(x,y)
or g(x,y,seg,tp)
where
x,y,seg,tp
are coordinates. If the original function f
had additional arguments, then these may be included in the call
to g
, and will be passed to f
.
Value
A function in the R\ language.
It also belongs to the class "linfun"
which has methods
for plot
, print
etc.
Author(s)
Adrian Baddeley Adrian.Baddeley@curtin.edu.au and Rolf Turner rolfturner@posteo.net
See Also
methods.linfun
for methods applicable to
"linfun"
objects.
Examples
f <- function(x,y,seg,tp) { x+y }
g <- linfun(f, simplenet)
plot(g)
X <- runiflpp(3, simplenet)
g(X)
Z <- as.linim(g)
f <- function(x,y,seg,tp, mul=1) { mul*(x+y) }
g <- linfun(f, simplenet)
plot(g)
plot(g, mul=10)
g(X, mul=10)
Z <- as.linim(g, mul=10)