Learn R Programming

spatstat.geom (version 3.3-2)

with.hyperframe: Evaluate an Expression in Each Row of a Hyperframe

Description

An expression, involving the names of columns in a hyperframe, is evaluated separately for each row of the hyperframe.

Usage

# S3 method for hyperframe
with(data, expr, ...,
                         simplify = TRUE,
                         ee = NULL, enclos=NULL)

Value

Normally a list of length

\(n\) (where \(n\) is the number of rows) containing the results of evaluating the expression for each row. If simplify=TRUE and each result is a single atomic value, then the result is a vector or factor containing the same values.

Arguments

data

A hyperframe (object of class "hyperframe") containing data.

expr

An R language expression to be evaluated.

...

Ignored.

simplify

Logical. If TRUE, the return value will be simplified to a vector whenever possible.

ee

Alternative form of expr, as an object of class "expression".

enclos

An environment in which to search for objects that are not found in the hyperframe. Defaults to parent.frame().

Author

Adrian Baddeley Adrian.Baddeley@curtin.edu.au

and Rolf Turner rolfturner@posteo.net

Details

This function evaluates the expression expr in each row of the hyperframe data. It is a method for the generic function with.

The argument expr should be an R language expression in which each variable name is either the name of a column in the hyperframe data, or the name of an object in the parent frame (the environment in which with was called.) The argument ee can be used as an alternative to expr and should be an expression object (of class "expression").

For each row of data, the expression will be evaluated so that variables which are column names of data are interpreted as the entries for those columns in the current row.

For example, if a hyperframe h has columns called A and B, then with(h, A != B) inspects each row of data in turn, tests whether the entries in columns A and B are equal, and returns the \(n\) logical values.

See Also

hyperframe, plot.hyperframe

Examples

Run this code
  # generate Poisson point patterns with intensities 10 to 100
   H <- hyperframe(L=seq(10,100, by=10))
if(require(spatstat.random)) {
   X <- with(H, rpoispp(L))
} else {
   X <- with(H, runifrect(rpois(1, L)))
}

Run the code above in your browser using DataLab