4. S4クラスオブジェクトとは?
• The data contained in an object from an S4 class is defined by the slots in the class definition.
• Each slot in an object is a component of the object; like components (that is, elements) of a list,
these may be extracted and set, using the function slot() or more often the operator "@". However,
they differ from list components in important ways. First, slots can only be referred to by name, not
by position, and there is no partial matching of names as with list elements.
• All the objects from a particular class have the same set of slot names; specifically, the slot names
that are contained in the class definition. Each slot in each object always is an object of the class
specified for this slot in the definition of the current class. The word "is" corresponds to the R
function of the same name (is), meaning that the class of the object in the slot must be the same as
the class specified in the definition, or some class that extends the one in the definition (a subclass).
• A special slot name, .Data, stands for the ‘data part’ of the object. An object from a class with a data
part is defined by specifying that the class contains one of the R object types or one of the special
pseudo-classes, matrix or array, usually because the definition of the class, or of one of its
superclasses, has included the type or pseudo-class in its contains argument. A second special slot
name, .xData, is used to enable inheritance from abnormal types such as "environment" See the
section on inheriting from non-S4 classes for details on the representation and for the behavior of S3
methods with objects from these classes.
• Some slot names correspond to attributes used in old-style S3 objects and in R objects without an
explicit class, for example, the names attribute. If you define a class for which that attribute will be
set, such as a subclass of named vectors, you should include "names" as a slot. See the definition of
class "namedList" for an example. Using the names() assignment to set such names will generate a
warning if there is no names slot and an error if the object in question is not a vector type. A slot
called "names" can be used anywhere, but only if it is assigned as a slot, not via the default names()
assignment.
4
from https://stat.ethz.ch/R-manual/R devel/library/methods/html/Classes_Details.html
5. S4クラスオブジェクトとは?
• The data contained in an object from an S4 class is defined by the slots in the class definition.
• Each slot in an object is a component of the object; like components (that is, elements) of a list,
these may be extracted and set, using the function slot() or more often the operator "@". However,
they differ from list components in important ways. First, slots can only be referred to by name, not
by position, and there is no partial matching of names as with list elements.
• All the objects from a particular class have the same set of slot names; specifically, the slot names
that are contained in the class definition. Each slot in each object always is an object of the class
specified for this slot in the definition of the current class. The word "is" corresponds to the R
function of the same name (is), meaning that the class of the object in the slot must be the same as
the class specified in the definition, or some class that extends the one in the definition (a subclass).
• A special slot name, .Data, stands for the ‘data part’ of the object. An object from a class with a data
part is defined by specifying that the class contains one of the R object types or one of the special
pseudo-classes, matrix or array, usually because the definition of the class, or of one of its
superclasses, has included the type or pseudo-class in its contains argument. A second special slot
name, .xData, is used to enable inheritance from abnormal types such as "environment" See the
section on inheriting from non-S4 classes for details on the representation and for the behavior of S3
methods with objects from these classes.
• Some slot names correspond to attributes used in old-style S3 objects and in R objects without an
explicit class, for example, the names attribute. If you define a class for which that attribute will be
set, such as a subclass of named vectors, you should include "names" as a slot. See the definition of
class "namedList" for an example. Using the names() assignment to set such names will generate a
warning if there is no names slot and an error if the object in question is not a vector type. A slot
called "names" can be used anywhere, but only if it is assigned as a slot, not via the default names()
assignment.
5
要は
複雑なオブジェクト構造
6. S4クラスオブジェクトとは?
• The data contained in an object from an S4 class is defined by the slots in the class definition.
• Each slot in an object is a component of the object; like components (that is, elements) of a list,
these may be extracted and set, using the function slot() or more often the operator "@". However,
they differ from list components in important ways. First, slots can only be referred to by name, not
by position, and there is no partial matching of names as with list elements.
• All the objects from a particular class have the same set of slot names; specifically, the slot names
that are contained in the class definition. Each slot in each object always is an object of the class
specified for this slot in the definition of the current class. The word "is" corresponds to the R
function of the same name (is), meaning that the class of the object in the slot must be the same as
the class specified in the definition, or some class that extends the one in the definition (a subclass).
• A special slot name, .Data, stands for the ‘data part’ of the object. An object from a class with a data
part is defined by specifying that the class contains one of the R object types or one of the special
pseudo-classes, matrix or array, usually because the definition of the class, or of one of its
superclasses, has included the type or pseudo-class in its contains argument. A second special slot
name, .xData, is used to enable inheritance from abnormal types such as "environment" See the
section on inheriting from non-S4 classes for details on the representation and for the behavior of S3
methods with objects from these classes.
• Some slot names correspond to attributes used in old-style S3 objects and in R objects without an
explicit class, for example, the names attribute. If you define a class for which that attribute will be
set, such as a subclass of named vectors, you should include "names" as a slot. See the definition of
class "namedList" for an example. Using the names() assignment to set such names will generate a
warning if there is no names slot and an error if the object in question is not a vector type. A slot
called "names" can be used anywhere, but only if it is assigned as a slot, not via the default names()
assignment.
6
fit$
では取り出せない
要は
複雑なオブジェクト構造
7. S4クラスオブジェクトとは?
• The data contained in an object from an S4 class is defined by the slots in the class definition.
• Each slot in an object is a component of the object; like components (that is, elements) of a list,
these may be extracted and set, using the function slot() or more often the operator "@". However,
they differ from list components in important ways. First, slots can only be referred to by name, not
by position, and there is no partial matching of names as with list elements.
• All the objects from a particular class have the same set of slot names; specifically, the slot names
that are contained in the class definition. Each slot in each object always is an object of the class
specified for this slot in the definition of the current class. The word "is" corresponds to the R
function of the same name (is), meaning that the class of the object in the slot must be the same as
the class specified in the definition, or some class that extends the one in the definition (a subclass).
• A special slot name, .Data, stands for the ‘data part’ of the object. An object from a class with a data
part is defined by specifying that the class contains one of the R object types or one of the special
pseudo-classes, matrix or array, usually because the definition of the class, or of one of its
superclasses, has included the type or pseudo-class in its contains argument. A second special slot
name, .xData, is used to enable inheritance from abnormal types such as "environment" See the
section on inheriting from non-S4 classes for details on the representation and for the behavior of S3
methods with objects from these classes.
• Some slot names correspond to attributes used in old-style S3 objects and in R objects without an
explicit class, for example, the names attribute. If you define a class for which that attribute will be
set, such as a subclass of named vectors, you should include "names" as a slot. See the definition of
class "namedList" for an example. Using the names() assignment to set such names will generate a
warning if there is no names slot and an error if the object in question is not a vector type. A slot
called "names" can be used anywhere, but only if it is assigned as a slot, not via the default names()
assignment.
7
fit$
では取り出せない
fit@
で取り出す
要は
複雑なオブジェクト構造