Description Usage Arguments Details Value Warning Note Author(s) See Also Examples
Rebuilds an object to its original class from a list which was usually obtained using unObject. The original class is deduced using the Class.
value and its S3 constructor will be called using all other values as properties.
1 | reObject(o, showStructure = 0)
|
o |
The list attempted to convert to its original Object. |
showStructure |
Flag to show/debug the conversion course. It can be 1, 2 or 0. |
The original class (x$Class.
value) is called without any parameter, then all properties (names) in the list are set using assign
. The procedure is recursive called if an object of class list is found inside x. If the original object was extended from Object, this object have to be already defined using S3 methodology, otherwise an error would occur.
Object of original class given by x$Class.
It could take some seconds for large and/or complex objects.
It is very important that if the original class was extendend from Object, this class and its methods are already defined, otherwise unexpected behaviour and/or errors would occur.
Victor Trevino
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 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
x <- reObject(uo)
class(x)
names(x)
x$x
x$y
### saving/retriving
library(R.oo)
o <- Object()
o$x = 1
o$y = 2
uo <- unObject(o)
uoTempFile <- file.path(tempdir(), "uo.Rdata")
save(uo, file=uoTempFile)
### perhaps other session here
library(R.oo)
#if your object requiere other sub-class (extend Object) and/or method definition,
#load it here before using reObject otherwise an error would occur.
load(uoTempFile)
class(uo) ## uo now is a list
uo
x <- reObject(uo)
class(x) ### now x is Object
names(x)
x$x
x$y
x
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.