S4Vectors (version 0.10.1)

Vector-class: Vector objects

Description

The Vector virtual class serves as the heart of the S4Vectors package and has over 90 subclasses. It serves a similar role as vector in base R.

The Vector class supports the storage of global and element-wise metadata:

  1. Theglobalmetadata annotates the object as a whole: this metadata is accessed via themetadataaccessor and is represented as an ordinary list;
  2. Theelement-wisemetadata annotates individual elements of the object: this metadata is accessed via themcolsaccessor (mcolsstands formetadata columns) and is represented as aDataTableobject (i.e. as an instance of a concrete subclass ofDataTable, e.g. aDataFrameobject), with a row for each element and a column for each metadata variable. Note that the element-wise metadata can also beNULL.

To be functional, a class that inherits from Vector must define at least a length and a "[" method.

Arguments

Displaying

[FOR ADVANCED USERS OR DEVELOPERS]

Displaying of a Vector object is controlled by 2 internal helpers, classNameForDisplay and showAsCell.

For most objects classNameForDisplay(x) just returns 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 classNameForDisplay returns 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 classNameForDisplay and showAsCell are generic functions so developers can implement methods to control how their own Vector extension gets displayed.

See Also

  • Rle,Hits,IRangesandXRawfor example implementations.
  • Vector-comparisonfor comparing, ordering, and tabulating vector-like objects.
  • Vector-setopsfor set operations on vector-like objects.
  • Listfor a direct Vector extension that serves a similar role aslistin base R.
  • extractListfor grouping elements of a vector-like object into a list-like object.
  • DataTablewhich is the type of objects returned by themcolsaccessor.
  • TheAnnotatedclass, which Vector extends.

Examples

Run this code
showClass("Vector")  # shows (some of) the known subclasses

Run the code above in your browser using DataCamp Workspace