probe {scope} | R Documentation |
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.
probe(x, this, FUN = "max", that = this, scope = NULL, ...)
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. |
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.
A vector of values of same length and mode as that
.
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)