Context objects allow Callback objects to access and modify data. The following packages implement context subclasses:

## Details

Context is an abstract base class. A subclass inherits from Context. Data is stored in public fields. Access to the data can be restricted with active bindings (see example).

## Public fields

id

(character(1))
Identifier of the object. Used in tables, plot and text output.

label

(character(1))
Label for this object. Can be used in tables, plot and text output instead of the ID.

## Methods

### Method new()

Creates a new instance of this R6 class.

### Method print()

Print object.

#### Arguments

deep

Whether to make a deep clone.

## Examples

library(data.table)
library(R6)

# data table with column x an y
data = data.table(x = runif(10), y = sample(c("A", "B"), 10, replace = TRUE))

# context only allows to access column y
ContextExample = R6Class("ContextExample",
inherit = Context,
public = list(
data = NULL,

initialize = function(data) {
self$data = data } ), active = list( y = function(rhs) { if (missing(rhs)) return(self$data$y) self$data$y = rhs } ) ) context = ContextExample$new(data)

# retrieve content of column y
context$y #> [1] "A" "B" "A" "B" "A" "A" "A" "B" "B" "B" # change content of column y to "C" context$y = "C"