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 |
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.
activate(.data, what) active(x) ## Default S3 method: active(x) active(x) <- value ## Default S3 replacement method: active(x) <- value
activate(.data, what) active(x) ## Default S3 method: active(x) active(x) <- value ## Default S3 replacement method: active(x) <- value
.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 |
A object of class '.data'
# 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")
# 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")