groupVec
is a class which groups together a list of vectors so that
they can act like a single atomic vector.
groupVecVirtual
is a virtual
class corresponding to
groupVec
; all the
groupVec
methods are actually
defined on the
groupVecVirtual
class for easy inheritance without
class coercion.
list
) the list of vector columns.
character
) the column names.
CLASS
) the column classes.
groupVec
is a class for objects that act as vectors, but
are actually made up of a collection of vectors of the same length
which are accessed together and would generally expected to be printed
as if they were simple atomic vectors. The
groupVec
class takes care
of the basic vector operations, such as subscripting and length;
extending classes will have to take care of the meaning of the
collection of vectors, and more specific operations such as
character coercion. Extending classes may have other information
(probably not the same length) in other slots as well, and subscripting
on a
groupVec
extended class carries this information along unchanged.
Because of coercion done in method selection, there is
also a virtual class associated with the
groupVec
, called
groupVecVirtual
.
groupVec
extends
groupVecVirtual
directly, and all of
the methods for
groupVec
objects are defined on the
groupVecVirtual
class and not the
groupVec
class itself. Extending classes should
include
groupVec
and
groupVecVirtual
in their representation
in order to inherit the slots and methods of groupVecs.
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, and all the vectors are the same length. It 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. Since 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 since the 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 doesn't even have to know
that they are stored separately.
One other thing to note is that the objects in
groupVec
columns
can be any class that has a well-defined
length, not just atomic vectors. In particular, that allows one
groupVec
object to hold other
groupVec
objects, lists,
data.frames
,
any type of S-PLUS 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"
, since any S-PLUS object has an
is
relationship with the special
ANY
class.
See individual function documentation for more information on the following
functions.
There is a
groupVec
class validity function,
groupVecValid
; however
for efficiency it is NOT set as the validity funtion for the class.
There is also a validity function that user-defined extending
classes with set column names and column classes can use for
checking validity, groupVecExtValid. The
groupVec
constructor function is
called
groupVec
.
Although the slots of a
groupVec
can be accessed directly, it is not
recommended. Instead, there are several access functions which can be
used on the left or right side of assignments, and which preserve the
validity of
groupVec
objects. These functions are
groupVecColumn
, for
accessing a single column;
GV.data
, for accessing the entire data
list;
groupVecNames
, for accessing the column names; and
groupVecClass
, for
accessing the column classes.
Several methods have been defined for
groupVec
objects for standard
vector operations: subscripting with
[]
and
[[]]
on the left or right side
of an assignment,
length
on the left or right side,
concat
, and
is.na
all operate on
groupVec
objects as if they
were atomic vectors.