When an S7 class inherits from an existing base type, it can be useful
to work with the underlying object, i.e. the S7 object stripped of class
and properties.
Usage
S7_data(object)
S7_data(object, check = TRUE) <- value
Arguments
- object
An object from a S7 class
- check
If TRUE
, check that value
is of the correct type and run
validate()
on the object before returning.
- value
Object used to replace the underlying data.
Value
S7_data()
returns the data stored in the base object;
S7_data<-()
is called for its side-effects and returns object
invisibly.
Examples
text <- new_class("text", parent = class_character)
y <- text(c(foo = "bar"))
y
#> <text> Named chr "bar"
#> - attr(*, "names")= chr "foo"
S7_data(y)
#> foo
#> "bar"
S7_data(y) <- c("a", "b")
y
#> <text> Named chr [1:2] "a" "b"
#> - attr(*, "names")= chr [1:2] "foo" NA