scope-package {scope}R Documentation

Data Manipulation Using Arbitrary Row and Column Criteria

Description

Calculate, per data frame row, a value that depends on information in a relevant subset of rows and columns. These functions create and refine scope objects, which identify relevant rows on a per-row basis. Columns can be aggregated within relevant scopes to aid identification of a row of interest, from which an arbitrary column value can be selected.

Details

Package: scope
Type: Package
Version: 1.0-2
Date: 2006-04-17
License: GPL version 2 or newer

Given a data frame of length n, scope() creates a list of length n, each element of which is a vector of length n or smaller (a scope object). The vectors hold data frame row names that are selected by some criterion specified as an argument to scope(). Scope objects may be sequentially refined by passing to scope() with additional criteria. For a given scope object, score() returns a vector of the lengths of each element. scoop() effectively dereferences the scope object, returning a vector of values of a specified column for scope elements of length one (1). skim() is like tapply(), applying an aggregate function to cells specified by scope elements. Some aggregate functions are likely to return values that occur once among their arguments (often min() and max(), but probably not mean()); passing such functions to skim() creates a vector that can be used with scope() to identify the matching row. probe() is a short-cut that uses skim(), scope(), and scoop() to find the value in an arbitrary column where the value in a related column matches the aggregated value.

Author(s)

Tim Bergsma

Maintainer: Tim Bergsma <timb@metrumrg.com>

See Also

tapply

Examples

data(Theoph)
#What is the time since the maximum concentration within subject?
Scope <- scope(Theoph,'Subject')
Tmax  <- probe(Theoph,'conc',that='Time',scope=Scope)
Theoph$SinceMax <- Theoph$Time - Tmax

[Package scope version 1.0-2 Index]