Converts an object of class "fv" to an R language function.
# S3 method for fv
as.function(x, ..., value=".y", extrapolate=FALSE)  # S3 method for rhohat
as.function(x, ..., value=".y", extrapolate=TRUE)
Object of class "fv" or "rhohat".
Ignored.
Optional. Character string or character vector selecting
    one or more of the columns of x
    for use as the function value. See Details.
Logical, indicating whether to extrapolate the function
    outside the domain of x. See Details.
A function(r) or function(r,what)
  where r is the name of the original argument of the function table.
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.
# NOT RUN {
  K <- Kest(cells)
  f <- as.function(K)
  f
  f(0.1)
  g <- as.function(K, value=c("iso", "trans"))
  g
  g(0.1, "trans")
# }
Run the code above in your browser using DataLab