Learn R Programming

galgo (version 1.4)

unObject: Converts variables from class Object (and derived classes) to list

Description

Converts objects derived from class Object to a list object that preserve the properties (data) and can be accessed using the same R syntax. It is primarly used to explore the data or to save the object as an R object independent of the original methods.

Usage

unObject(...)

Arguments

...

Variables of class Object (or list containing some Object).

Value

Return a list containg all values of the object. If x contains a list or other Object, these are represented also as a list.The original class of the object is stored in "Class." value.

Warning

The CPU time consumed by this method depends on the complexity of x. It is commonly very fast but can be a nuisance when x contains many nested objects of class Object (or many lists containing Objects).

Details

In R.oo package, all objects are internally represented as enviroment objects (see R.oo package) to give the ``by value'' functionality. However, this representation is not suitable to save, retrive or explore the data as easy as common objects in R. This method converts an object derived from class Object to a common list object preserving all data except the original methods. It is very useful when an object of class Object contains other objects derived from same class Object.

See Also

Object, reObject, unObject.list.

Examples

Run this code
# NOT RUN {
library(R.oo)  # needed library
o <- Object()
o$x = 1
o$y = 2
o$x
o$y
o
class(o)
names(o)
uo <- unObject(o)
uo
# }

Run the code above in your browser using DataLab