Next: vectors
Up: MacAnova Help File
Previous: vecread_keys
Contents
Usage:
vector(x1,x2,...,xk [,KeyPhrases]) where x1, x2, ... all have the same
type, REAL, LOGICAL, or CHARACTER, or are structures with components
all of the same type
KeyPhrases can be labels:lab, notes:Notes and silent:T, where labs and
Notes are CHARACTER scalars or vectors.
|
Keywords:
variables, combining variables, character variables, null variables
vector(x1, x2, ..., xk) combines scalars x1, x2, ... xk into a vector of
length k. For example, you can enter a small set of data by
Cmd> x <- vector(3.5, 9.6, 2.5, 2.3, 7.7, 2.6, 6.3, 6.5, 6.6, 4.1)
The arguments x1, x2, ..., xk can be REAL, LOGICAL or CHARACTER and must
all have the same type. For example, you can create a CHARACTER vector
by
Cmd> varNames <- vector("Length","Width", "Weight")
vector() is identical to cat(). However, cat() is a deprecated
function, that is, it will remain available for the immediate future,
but at some time it may be disabled. Use vector() instead.
Arguments may also be vectors. In that case vector(x1, x2, ...., xk)
combines all the arguments into a single vector. For example,
Cmd> vector(run(3), run(3,1))
is equivalent to
Cmd> vector(1,2,3,3,2,1).
More generally, any or all of the arguments may be vectors, matrices or
arrays, as long as they all have the same type. In that case,
vector(x1, x2, ...., xk) has the same effect as vector(vector(x1),
vector(x2), ...., vector(xk)), combining all the elements of its
arguments into one long vector. See the next paragraph for what
vector(x) does when x is a matrix or array.
vector(x) creates a vector from a matrix or array x by "unravelling" it,
with the first subscript changing fastest, the second changing next
fastest, etc. Specifically, if the dimensions of x are n1, n2, ..., nk,
vector(x) is a vector with length n1*n2*...*nk, with elements
x[1,1,...,1], x[2,1,...,1], ..., x[n1,1,...,1], x[1,2,...,1],
x[2,2,...,1], ..., x[n1,2,...,1], ..., x[1,3,...,1], ...,
x[n1,n2,...,nk]. x may be REAL, LOGICAL, or CHARACTER.
When Str is a structure with n components, vector(Str) is a vector
equivalent to vector(vector(Str[1]),...,vector(Str[n])), defined
recursively if any component is a structure. All the data components
must be of the same type, REAL, LOGICAL or CHARACTER. This should not
be confused with strconcat() which combines structures into a larger
structure.
Any argument of type NULL is ignored. For example, vector(NULL, a) or
vector(a, NULL) are equivalent to vector(a). When all arguments to
vector() have type NULL, so does the result.
You can specify labels for the first (and only) dimension of the result
using keyword 'labels'. See topic 'labels' for details.
You can attach a CHARACTER vector of descriptive notes to the result
using keyword phrase 'notes:Notes'. See topic 'notes' for details.
After
Cmd> y <- vector(x)
where x is already a vector, y will have the same coordinate labels or
descriptive notes as x.
See also topics 'vectors', 'structures'.
Gary Oehlert
2003-01-15