skim {scope}R Documentation

Aggregate Across Data Frame Subsets Defined by a Scope Object.

Description

Apply a function to values in the specified data frame column, across each group of rows specified in the scope object.

Usage

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

Arguments

x A data frame.
this A column name in x, the main argument to FUN.
FUN An aggregate function.
scope A scope object, e.g. created by scope().
... Extra arguments to pass to FUN.

Details

The default scope is all rows. The default function is max(...). Remember that skim() returns a data vector, not a scope object. For functions that return one of their arguments (perhaps max and min but perhaps not mean) the result of skim() can be passed back to scope() to ‘probe’ for the row from which the value originated. There is a danger that more or fewer than one row will be detected, so check with score().

Value

A vector of same length as this giving aggregated values.

See Also

scope, score, scoop, probe

Examples

data(Theoph)
#What is the maximum concentration for each subject?
S <- scope(Theoph,'Subject')
m <- skim(Theoph,'conc',scope=S)

[Package scope version 2.2 Index]