s4list | R Documentation |
Convert S4 objects to lists and vice versa. Useful for declassing an S4
object while keeping track of it's class using attributes (see section
S4 Class Definition Attributes below for more details). Both
ListToS4
and S4ToList
are recursive functions, affecting
all lists/S4 objects contained as sub-lists/sub-objects
S4ToList(object)
IsS4List(x)
ListToS4(x)
## Default S3 method:
S4ToList(object)
## S3 method for class 'list'
S4ToList(object)
object |
An S4 object |
x |
A list with an S4 class definition
(“ |
S4ToList
: A list with an S4 class definition attribute
IsS4List
: TRUE
if x
is a list with an S4 class
definition attribute
ListToS4
: An S4 object as defined by the S4 class definition
attribute
S4 classes are scoped to the package and class name. In order to properly
track which class a list is generated from in order to build a new one,
these function use an attribute
to denote the
class name and package of origin. This attribute is stored as 1-length
character vector named “classDef
” and takes the form
of “package:class
”
ClassKey()
# Turn an S4 object into a list
pbmc.list <- S4ToList(pbmc_small)
class(pbmc.list)
attributes(pbmc.list)
str(pbmc.list$reductions)
IsS4List(pbmc.list)
pbmc2 <- ListToS4(pbmc.list)
pbmc2
class(pbmc2)
Reductions(pbmc2)
validObject(pbmc2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.