Vector objects

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.

classes, methods


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.

  • class:DataTableORNULL
  • DataTableORNULL-class
  • DataTableORNULL
  • class:Vector
  • Vector-class
  • Vector
  • length,Vector-method
  • lengths,Vector-method
  • NROW,Vector-method
  • ROWNAMES,Vector-method
  • elementMetadata
  • elementMetadata,Vector-method
  • mcols
  • mcols,Vector-method
  • values
  • values,Vector-method
  • elementMetadata<-
  • elementMetadata<-,Vector-method
  • mcols<-
  • mcols<-,Vector-method
  • values<-
  • values<-,Vector-method
  • rename
  • rename,vector-method
  • rename,Vector-method
  • as.logical,Vector-method
  • as.integer,Vector-method
  • as.numeric,Vector-method
  • as.double,Vector-method
  • as.complex,Vector-method
  • as.character,Vector-method
  • as.raw,Vector-method
  • coerce,Vector,vector-method
  • coerce,Vector,logical-method
  • coerce,Vector,integer-method
  • coerce,Vector,numeric-method
  • coerce,Vector,double-method
  • coerce,Vector,complex-method
  • coerce,Vector,character-method
  • coerce,Vector,raw-method
  • coerce,Vector,factor-method
  • coerce,Vector,data.frame-method
  • as.env,Vector-method
  • as.list.Vector
  • as.list,Vector-method
  • [,Vector-method
  • [<-,Vector-method
  • replaceROWS,Vector-method
  • window
  • window.Vector
  • window,Vector-method
  • head
  • head.Vector
  • head,Vector-method
  • tail
  • tail.Vector
  • tail,Vector-method
  • append,Vector,Vector-method
  • classNameForDisplay
  • classNameForDisplay,ANY-method
  • classNameForDisplay,AsIs-method
  • showAsCell
  • showAsCell,ANY-method
  • showAsCell,Vector-method
  • parallelVectorNames
  • parallelVectorNames,ANY-method
showClass("Vector")  # shows (some of) the known subclasses
Documentation reproduced from package S4Vectors, version 0.10.1, License: Artistic-2.0

Community examples

Looks like there are no examples yet.