Learn R Programming

spatstat.explore (version 3.0-6)

as.function.rhohat: Convert Function Table to Function

Description

Converts an object of class "rhohat" to an R language function.

Usage

# S3 method for rhohat
as.function(x, ..., value=".y", extrapolate=TRUE)

Value

A function(r) or function(r,what)

where r is the name of the original argument of the function table.

Arguments

x

Object of class "rhohat", produced by the function rhohat.

...

Ignored.

value

Optional. Character string or character vector selecting one or more of the columns of x for use as the function value. See Details.

extrapolate

Logical, indicating whether to extrapolate the function outside the domain of x. See Details.

Author

Adrian Baddeley Adrian.Baddeley@curtin.edu.au and Rolf Turner r.turner@auckland.ac.nz

Details

An object of class "rhohat" is essentially a data frame of estimated values of the function \(rho(x)\) as described in the help file for rhohat.

Sometimes it is useful to convert the function value table to a function in the R language. This is done by as.function.rhohat. It converts an object x of class "rhohat" to an R function f.

The command as.function.rhohat is a method for the generic command as.function for the class "rhohat".

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.

See Also

rhohat, methods.rhohat, as.function.fv.

Examples

Run this code
  g <- rhohat(cells, "x")
  f <- as.function(g)
  f
  f(0.1)

Run the code above in your browser using DataLab