Next: vt()
Up: MacAnova Help File
Previous: vector()
Contents
Usage:
Create a vector: x <- vector(x1,x2, x3, ...)
Extract element(s) x[i], i an integer scalar or vector or LOGICAL
vector
|
Keywords:
variables, syntax
A vector is an array with only one dimension, its length. It can be
thought of as just a list of one or more numbers (REAL vector), logical
values (LOGICAL vector) or strings (CHARACTER vector). You can't mix
different types of data in a single vector. For that you need a
structure (see structure() and 'structures').
The most usual way to create a vector is to use vector():
Cmd> x <- vector(1,3,2.5,6) # create REAL vector
Cmd> y <- vector("Hi","Lois") # create CHARACTER vector
Cmd> z <- vector(T,T,F,F,T) # create LOGICAL vector
Cmd> list(x,y,z) # all are vectors, having only 1 dimension
x REAL 4
y CHAR 2
z LOGIC 5
Practically always, MacAnova commands treat a n by 1 matrix (column
vector) or a n by 1 by 1 ... by 1 array the same as a vector. For
example, if y is a n by p matrix, then factor(y[,3]) is legal, even
though factor() expects a vector as argument, because y[,3] has only one
column. Moreover, isvector(x) is True when x is a vector, a n by 1
matrix, or a n by 1 by 1 ... by 1 array.
Conversely, in a context requiring a matrix, practically always MacAnova
treats a vector of length n as a n by 1 matrix.
See also topics vector(), isvector(), factor(), 'matrices'.
Gary Oehlert
2003-01-15