The Vector class supports the storage of global and element-wise metadata:
metadataaccessor and is represented as an ordinary list;
mcolsstands for metadata columns) and is represented as a DataTable object (i.e. as an instance of a concrete subclass of DataTable, e.g. a DataFrame object), with a row for each element and a column for each metadata variable. Note that the element-wise metadata can also be
To be functional, a class that inherits from Vector must define at
length and a
xis a Vector object.
length(x): Get the number of elements in
lengths(x, use.names=TRUE): Get the length of each of the elements. Note: The
lengthsmethod for Vector objects is currently defined as an alias for
elementNROWS(with addition of the
use.namesargument), so is equivalent to
sapply(x, NROW), not to
sapply(x, length). See
?BiocGenerics::lengthsin the BiocGenerics package for more information about this.
NROW(x): Defined as
length(x)for any Vector object that is not a DataTable object. If
xis a DataTable object, then it's defined as
names(x) <- value: Get or set the names of the elements in the Vector.
rename(x, value, ...): Replace the names of
xaccording to a mapping defined by a named character vector, formed by concatenating
valuewith any arguments in
.... The names of the character vector indicate the source names, and the corresponding values the destination names. This also works on a plain old
nlevels(x): Returns the number of factor levels.
mcols(x) <- value: Get or set the metadata columns. If
use.names=TRUEand the metadata columns are not
NULL, then the names of
xare propagated as the row names of the returned DataTable object. When setting the metadata columns, the supplied value must be
NULLor a DataTable object holding element-wise metadata.
elementMetadata(x) <- value,
values(x) <- value: Alternatives to
mcolsfunctions. Their use is discouraged.
Vector, to a
data.frameby first coercing the
as.vector. Note that many
Vectorderivatives do not support
as.vector, so this coercion is possible only for certain types.
as.env(x): Constructs an environment object containing the elements of
xis a Vector object or regular R vector object. The R vector object methods for
windoware defined in this package and the remaining methods are defined in base R.
x[i, drop=TRUE]: If defined, returns a new Vector object made of selected elements
i, which can be missing; an NA-free logical, numeric, or character vector; or a logical Rle object. The
dropargument specifies whether or not to coerce the returned sequence to an ordinary vector.
x[i] <- value: Replacement version of
xis a Vector object.
c(x, ...): Combine
xand the Vector objects in
...together. Any object in
...must belong to the same class as
x, or to one of its subclasses, or must be
NULL. The result is an object of the same class as
append(x, values, after = length(x)): Insert the
xat the position given by
valuesmust have an
elementTypethat extends that of
showAsCell. For most objects
class(x). However, for some objects it can return the name of a parent class that is more suitable for display because it's simpler and as informative as the real class name. See SimpleList objects (defined in this package) and CompressedList objects (defined in the IRanges package) for examples of objects for which
classNameForDisplayreturns the name of a parent class.
showAsCell(x)produces a character vector parallel to
x(i.e. with one string per vector element in
x) that contains compact string representations of each elements in
x. Note that
showAsCellare generic functions so developers can implement methods to control how their own Vector extension gets displayed.
showClass("Vector") # shows (some of) the known subclasses