A simple class of functions of spatial location
funxy(f, W)
A function
in the R language
with arguments x,y
(at least)
Window (object of class "owin"
) inside which the
function is well-defined.
A function
with the same arguments as f
,
which also belongs to the class "funxy"
.
This class has methods for
print
, plot
, contour
and persp
.
This creates an object of class "funxy"
.
This is a simple mechanism for handling a function
of spatial location
f
should be a function
in the R language.
The first two arguments of f
must be named x
and y
respectively.
W
should be a window (object of class "owin"
) inside which the
function f
is well-defined.
The function f
should be vectorised: that is,
if x
and y
are numeric vectors of the same length
n
, then v <- f(x,y)
should be a vector of length
n
.
The resulting function g <- funxy(f, W)
has the same formal
arguments as f
. It accepts numeric vectors x,y
as
described above, but if y
is missing, then x
may be
a point pattern (object of class "ppp"
or "lpp"
) from
which the coordinates should be extracted.
# NOT RUN {
f <- function(x,y) { x^2 + y^2 - 1}
g <- funxy(f, square(2))
g(0.2, 0.3)
g
g(cells[1:4])
# }
Run the code above in your browser using DataLab