View source: R/distancemetrics.R
invoke.metric | R Documentation |
Perform a desired geometrical operation using a specified distance metric.
invoke.metric(m, task, ..., evaluate=TRUE)
m |
Metric (object of class |
task |
Character string specifying the task. The name of a function that performs the desired operation for the Euclidean metric. |
... |
Input to the function that performs the geometrical operation
(matching the arguments of |
evaluate |
Logical value specifying whether to actually perform the
computation and return the result ( |
A ‘metric’ is a measure of distance between points in space.
An object of class "metric"
represents such a metric,
and supports many geometrical computations that involve
the metric. See metric.object
.
The argument task
should be the name of an existing function
in the spatstat family representing a geometrical operation, such
as computing pairwise distances, nearest-neighbour distances,
the distance map, and so on. The code will determine whether
this geometrical operation has a counterpart using the specified metric,
that is defined and supported in the object m
.
If so, then this operation will be applied to the
data specified in ...
, and the result will be returned.
For example, the spatstat function nndist.ppp
computes
nearest-neighbour distances using the Euclidean distance metric.
To calculate nearest-neighbour distances for a point pattern X
using another metric m
,
use invoke.metric(m, "nndist.ppp", X)
.
If evaluate=FALSE
, the computation is not performed,
and invoke.metric
simply returns a function to
perform the desired operation.
If evaluate=TRUE
(the default), the result of the computation has the
same format as the result of the computation using the existing
function named task
.
If evaluate=FALSE
, the result is a function
in the R language
to perform the desired operation;
or NULL
if the operation is not supported by the metric.
.
convexmetric
## nearest-neighbour distances using rectangular metric (L^1 metric)
d <- convexmetric(square(c(-1,1)))
y <- invoke.metric(d, "nndist.ppp", cells)
f <- invoke.metric(d, "nndist.ppp", cells, evaluate=FALSE)
y <- f(cells)
invoke.metric(d, "orderPizza", evaluate=FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.