as.function.fv | R Documentation |
Converts an object of class "fv"
to an R language function.
## S3 method for class 'fv' as.function(x, ..., value=".y", extrapolate=FALSE)
x |
Object of class |
... |
Ignored. |
value |
Optional. Character string or character vector selecting
one or more of the columns of |
extrapolate |
Logical, indicating whether to extrapolate the function
outside the domain of |
A function value table (object of class "fv"
)
is a convenient way of storing and plotting
several different estimates of the same function.
Objects of this class are returned
by many commands in spatstat,
such as Kest
,
which returns an estimate of Ripley's K-function
for a point pattern dataset.
Sometimes it is useful to convert the function value table
to a function
in the R language. This is done by
as.function.fv
. It converts an object x
of class "fv"
to an R function f
.
If f <- as.function(x)
then f
is an R function
that accepts a numeric argument and returns a corresponding value
for the summary function by linear interpolation between the values
in the table x
.
Argument values lying outside the range of the table
yield an NA
value (if extrapolate=FALSE
)
or the function value at the nearest endpoint of the range
(if extrapolate = TRUE
).
To apply different rules to the left and right extremes,
use extrapolate=c(TRUE,FALSE)
and so on.
Typically the table x
contains several columns of
function values corresponding to different edge corrections.
Auxiliary information for the table identifies one of these
columns as the recommended value.
By default, the values of the function f <- as.function(x)
are taken from this column of recommended values.
This default can be changed using the argument value
,
which can be a character string or character vector of names of
columns of x
. Alternatively value
can be one of
the abbreviations used by fvnames
.
If value
specifies a single column of the table,
then the result is a function f(r)
with a single numeric
argument r
(with the same name as the orginal argument
of the function table).
If value
specifies several columns of the table,
then the result is a function f(r,what)
where r
is the numeric argument and
what
is a character string identifying the column of values
to be used.
The formal arguments of the resulting function
are f(r, what=value)
, which
means that in a call to this function f
, the permissible values
of what
are the entries of the original vector value
;
the default value of what
is the first entry of value
.
The command as.function.fv
is a method for the generic command
as.function
.
A function(r)
or function(r,what)
where r
is the name of the original argument of the function table.
and \rolf
as.function.rhohat
,
fv
,
fv.object
,
fvnames
,
plot.fv
,
Kest
K <- Kest(cells) f <- as.function(K) f f(0.1) g <- as.function(K, value=c("iso", "trans")) g g(0.1, "trans")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.