probe {scope}R Documentation

Probe a Data Frame for Values Corresponding to a Scoped Aggregate

Description

For each row of a data frame, find the value in an arbitrary column and in the row where some other column has the scoped aggregated value.

Usage

probe(x, this, FUN = "max", that = this, scope = NULL, ...)

Arguments

x A data frame.
this A column name in x, to which FUN is applied, within scope.
FUN An aggregate function, preferably returning one of its arguments.
that The column from which to select return values, possibly the same as this.
scope A scope object, identifying rows across which FUN is applied.
... Extra arguments to FUN.

Details

probe() is a short-cut for a combination of skim(), scope(), and scoop(). That is, given a data frame and a scope object, aggregate on one column and use each aggregate value to find the row (if any) where the column value matches; return the value in an arbitrary column for that row. NA is returned if there is not exactly one match for the aggregate.

Value

A vector of values of same length and mode as that.

See Also

scope, score, skim, scoop

Examples

data(Theoph)
#What is the time of the maximum concentration within subject (per row)?
S <- scope(Theoph,'Subject')
T <- probe(Theoph,'conc',that='Time',scope=S)

[Package scope version 1.0-2 Index]