# R: Classes Corresponding to Basic Structures

StructureClasses {methods} | R Documentation

## Classes Corresponding to Basic Structures

### Description

The virtual class `structure` and classes that extend it are formal classes analogous to S language structures such as arrays and time-series.

### Usage

    ## The following class names can appear in method signatures,
    ## as the class in as() and is() expressions, and, except for
    ## the classes commented as VIRTUAL, in calls to new()

    "matrix"
    "array"
    "ts"

    "structure" ## VIRTUAL

### Objects from the Classes

Objects can be created by calls of the form `new(Class, ...)`, where `Class` is the quoted name of the specific class (e.g., `"matrix"`), and the other arguments, if any, are interpreted as arguments to the corresponding function, e.g., to function `matrix()`. There is no particular advantage over calling those functions directly, unless you are writing software designed to work for multiple classes, perhaps with the class name and the arguments passed in.

### Extends

The specific classes all extend class `"structure"`, directly, and class `"vector"`, by class `"structure"`.

### Methods

coerce
  Methods are defined to coerce arbitrary objects to these classes, by calling the corresponding basic function, for example, `as(x, "matrix")` calls `as.matrix(x)`.
Ops, Math
  Group methods (see, e.g., `S4groupGeneric`) are defined for combinations of structures and vectors (including special cases for array and matrix), implementing the concept of vector structures as in the reference.

### References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.

### Examples

    showClass("structure")

    ## explore a bit :
    showClass("ts")
    (ts0 <- new("ts"))
    str(ts0)

    showMethods("Ops") # six methods from these classes, but maybe many more

[Package methods version 2.6.0 Index]