Package 'activate'

Title: Activate to Determine the Context of Subsequent Manipulations
Description: A simple context-controlling mechanism to 'activate' a named sub-entity in an object. The generic functions are provided with bare default methods. It is expected that other packages will import the generic and specialize it.
Authors: Michael D. Sumner [aut, cre], Thomas Lin Pedersen [aut] (Original author of activate, in tidygraph.)
Maintainer: Michael D. Sumner <[email protected]>
License: GPL-3
Version: 0.0.0.9000
Built: 2024-11-19 05:11:00 UTC
Source: https://github.com/hypertidy/activate

Help Index


Determine the context of subsequent manipulations

Description

Many objects are composed of multiple named entities and it necessary to specify which sub-object is referenced during manipulations. The 'activate' verb does just that affects all subsequent manipulations until a new sub-object is activated. 'active' is a simple query function to get the currently active context.

Usage

activate(.data, what)

active(x)

## Default S3 method:
active(x)

active(x) <- value

## Default S3 replacement method:
active(x) <- value

Arguments

.data, x

An object with named entities

what

What should get activated? See methods for specifics.

value

the name to be used as the active sub-object

Value

A object of class '.data'

Examples

# See dev tidygraph and dev ncdump for some real examples, but as seen
# we can activate a generic object by setting or getting attr(x, 'active').
my_object <- structure(list(x = 1, y = 25), active = "y")
active(my_object)
activate(my_object, "x")