RectangularData-class: RectangularData objects

Description Accessors Subsetting Combining See Also Examples

Description

RectangularData is a virtual class with no slots to be extended by classes that aim at representing objects with a rectangular shape. Current RectangularData derivatives are DataFrame, DelayedMatrix, SummarizedExperiment, and Assays objects.

RectangularData derivatives are expected to support the 2D API: at least dim(), but also typically dimnames, [ (the 2D form x[i, j]), bindROWS(), and bindCOLS().

Accessors

In the following code snippets, x is a RectangularData derivative.

nrow(x), ncol(x): Get the number of rows and columns, respectively.

NROW(x), NCOL(x): Same as nrow(x) and ncol(x), respectively.

dim(x): Length two integer vector defined as c(nrow(x), ncol(x)).

rownames(x), colnames(x): Get the names of the rows and columns, respectively.

dimnames(x): Length two list of character vectors defined as list(rownames(x), colnames(x)).

Subsetting

In the code snippets below, x is a RectangularData derivative.

x[i, j, drop=TRUE]: Return a new RectangularData derivative of the same class as x made of the selected rows and columns.

For single row and/or column selection, the drop argument specifies whether or not to "drop the dimensions" of the result. More precisely, when drop=TRUE (the default), a single row or column is returned as a vector-like object (of length/NROW equal to ncol(x) if a single row, or equal to nrow(x) if a single column).

Not all RectangularData derivatives support the drop argument. For example DataFrame and DelayedMatrix objects support it (only for a single column selection for DataFrame objects), but SummarizedExperiment objects don't (drop is ignored for these objects and subsetting always returns a SummarizedExperiment derivative of the same class as x).

head(x, n=6L): If n is non-negative, returns the first n rows of the RectangularData derivative. If n is negative, returns all but the last abs(n) rows of the RectangularData derivative.

tail(x, n=6L): If n is non-negative, returns the last n rows of the RectangularData derivative. If n is negative, returns all but the first abs(n) rows of the RectangularData derivative.

subset(x, subset, select, drop=FALSE): Return a new RectangularData derivative using:

subset

logical expression indicating rows to keep, where missing values are taken as FALSE.

select

expression indicating columns to keep.

drop

passed on to [ indexing operator.

Combining

In the code snippets below, x is a RectangularData derivative.

rbind(...): Creates a new RectangularData derivative by combining the rows of the RectangularData derivatives in ....

cbind(...): Creates a new RectangularData derivative by combining the columns of the RectangularData derivatives in ....

See Also

Examples

1
showClass("RectangularData")  # shows (some of) the known subclasses

S4Vectors documentation built on Dec. 11, 2020, 2:02 a.m.