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, ...)
select(x, from, among = NULL, where, is,  ...)

Arguments

x A data frame (probe) or a column name (select)
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, or the name of an element in x of class scope.
... Extra arguments to FUN.
from A data frame.
among A scope object, or name of one in x.
where A column in x.
is A function.

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.

select() is a SQL-like reargumentation of probe(). See example.

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)
U <- select('Time',from=Theoph,among=S,where='conc',is='max')
# The T and U vectors above are not the same. You would need to switch 'conc' and 'Time' in
# the select argument above to do the same thing. 

[Package scope version 2.2 Index]