as: Force an object to belong to a class

Description DESeqAnalysis Description Basic Coercion Methods Author(s) References See Also Examples

Description

Coerce an object to a given class.

DESeqAnalysis

Supported coercion methods will extract any of these internal objects:

Description

as(object) returns the version of this object coerced to be the given Class. When used in the replacement form on the left of an assignment, the portion of the object corresponding to Class is replaced by value.

The operation of as() in either form depends on the definition of coerce methods. Methods are defined automatically when the two classes are related by inheritance; that is, when one of the classes is a subclass of the other.

Coerce methods are also predefined for basic classes (including all the types of vectors, functions and a few others).

Beyond these two sources of methods, further methods are defined by calls to the setAs function. See that documentation also for details of how coerce methods work. Use showMethods(coerce) for a list of all currently defined methods, as in the example below.

Basic Coercion Methods

Methods are pre-defined for coercing any object to one of the basic datatypes. For example, as(x, "numeric") uses the existing as.numeric function. These and all other existing methods can be listed as shown in the example.

Author(s)

Michael Steinbaugh

References

Chambers, John M. (2016) Extending R, Chapman & Hall. (Chapters 9 and 10.)

See Also

If you think of using try(as(x, cl)), consider canCoerce(x, cl) instead.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
data(deseq)

## DESeqAnalysis ====
dds <- as(deseq, "DESeqDataSet")
print(dds)
dt <- as(deseq, "DESeqTransform")
print(dt)
## Pulls the first results slotted.
res <- as(deseq, "DESeqResults")
contrastName(res)
summary(res)

steinbaugh/DESeqAnalysis documentation built on March 22, 2019, 5:51 p.m.