with.fv: Evaluate an Expression in a Function Table

View source: R/fv.R

with.fvR Documentation

Evaluate an Expression in a Function Table

Description

Evaluate an R expression in a function value table (object of class "fv").

Usage

## S3 method for class 'fv'
with(data, expr, ..., fun = NULL, enclos=NULL)

Arguments

data

A function value table (object of class "fv") in which the expression will be evaluated.

expr

The expression to be evaluated. An R language expression, which may involve the names of columns in data, the special abbreviations ., .x and .y, and global constants or functions.

...

Ignored.

fun

Logical value, specifying whether the result should be interpreted as another function (fun=TRUE) or simply returned as a numeric vector or array (fun=FALSE). See Details.

enclos

An environment in which to search for variables that are not found in data. Defaults to parent.frame().

Details

This is a method for the generic command with for an object of class "fv" (function value table).

An object of class "fv" is a convenient way of storing and plotting several different estimates of the same function. It is effectively a data frame with extra attributes. See fv.object for further explanation.

This command makes it possible to perform computations that involve different estimates of the same function. For example we use it to compute the arithmetic difference between two different edge-corrected estimates of the K function of a point pattern.

The argument expr should be an R language expression. The expression may involve

  • the name of any column in data, referring to one of the estimates of the function;

  • the symbol . which stands for all the available estimates of the function;

  • the symbol .y which stands for the recommended estimate of the function (in an "fv" object, one of the estimates is always identified as the recommended estimate);

  • the symbol .x which stands for the argument of the function;

  • global constants or functions.

See the Examples. The expression should be capable of handling vectors and matrices.

The interpretation of the argument fun is as follows:

  • If fun=FALSE, the result of evaluating the expression expr will be returned as a numeric vector, matrix or data frame.

  • If fun=TRUE, then the result of evaluating expr will be interpreted as containing the values of a new function. The return value will be an object of class "fv". (This can only happen if the result has the right dimensions.)

  • The default is fun=TRUE if the result of evaluating expr has more than one column, and fun=FALSE otherwise.

To perform calculations involving several objects of class "fv", use eval.fv.

Value

A function value table (object of class "fv") or a numeric vector or data frame.

Author(s)

\adrian

and \rolf

See Also

with, fv.object, eval.fv, Kest

Examples

  # compute 4 estimates of the K function
  X <- runifrect(42)
  K <- Kest(X)
  plot(K)

  # derive 4 estimates of the L function L(r) = sqrt(K(r)/pi)
  L <- with(K, sqrt(./pi))
  plot(L)

  # compute 4 estimates of V(r) = L(r)/r
  V <- with(L, ./.x)
  plot(V)

  # compute the maximum absolute difference between
  # the isotropic and translation correction estimates of K(r)
  D <- with(K, max(abs(iso - trans)))

spatstat.core documentation built on May 18, 2022, 9:05 a.m.