Learn R Programming

splusTimeDate (version 2.5.0-137)

groupVec-class: Group Vector Class

Description

groupVec is a class that groups a list of vectors so that they can act like a single atomic vector.

Arguments

Objects from the Class

Create objects using calls of the form new("groupVector", ...) or groupVector.

Slots

columns
(list) the list of vector columns.
names
(character) the column names.
classes
(character) the column classes.

GroupVec functions

  • groupVec: The groupVec constructor function.
  • groupVecValid: a groupVec class validity function.
  • groupVecExtValid: a validity function that user-defined extending classes with set column names and column classes can use for checking validity.
Although the slots of a groupVec can be accessed directly, it is not recommended. Instead, there are several access functions that you can use on the left or right side of assignments, and that preserve the validity of groupVec objects. These functions are:
  • groupVecColumn, for accessing a single column.
  • groupVecData, for accessing the entire data list.
  • groupVecNames, for accessing the column names.
  • groupVecClass, for accessing the column classes.
See individual function documentation for more information.

Methods

Several methods have been defined for groupVec objects for standard vector operations. All operate on groupVec objects as if they were atomic vectors:
  • subscripting with [] and [[]] on the left or right side of an assignment.
  • length on the left or right side of an assignment.
  • c, and is.na

Details

groupVec is a class for objects that act as vectors but are actually made up of a collection of vectors of the same length, and which are accessed together and would usually be expected to be printed as if they were simple atomic vectors.

The groupVec class manages the basic vector operations, such as subscripting and length. Extending classes must manage the meaning of the collection of vectors and more specific operations such as character coercion. Extending classes can have other information (although probably not the same length) in other slots. Subscripting on a groupVec-extended class carries this information along unchanged.

A groupVec object also has the following characteristics:

  • A valid groupVec object holds a list of vector "columns" with names and classes, where the vectors in the list correspond one-to-one with the names and classes.
  • Each vector satisfies an is relationship with its class.
  • All the vectors are the same length.

The object is intended to be used as a base class for defining other classes with fixed column names and classes but could also be used as a more dynamic list.

The difference between a groupVec and a data.frame, matrix, or other rectangular structure is that a groupVec is meant to hold objects whose columns really should not be considered as separate observations. For example, the timeDate class is a groupVec whose columns are the date and time of day in GMT, with additional slots for output format and time zone. Because the date can affect the time of day in the local time zone (if there is daylight savings time), and the time of day can affect the date in the local time zone (if the time zone conversion crosses a date boundary), and because each time and date in the timeDate object is displayed as a single character string containing both time and date, the time and date columns are not meant to be accessed separately, and in fact the user does not even have to know that they are stored separately.

The objects in groupVec columns do not have to be atomic vectors. They can be any class that has a well-defined length. This design allows one groupVec object to hold other groupVec objects, lists, data.frames, any type of R vectors, and user-defined types in its columns.

If type checking is not desired for a column, the column class can be set to "ANY", because any R object has an is relationship with the special "ANY" class.

See Also

groupVecValid, groupVecExtValid, groupVec function, groupVecColumn, groupVecData, groupVecNames, groupVecClasses.