Next: arrays Up: MacAnova Help File Previous: arithmetic   Contents

array()

Usage:
array(x,n1,n2,...[,KeyPhrases]) or array(x,dimVec [,KeyPhrases]), x
  REAL, LOGICAL or CHARACTER, n1, n2, ... positive integers or dimVec a
  vector of positive integers
KeyPhrases can be labels:structure(lab1,lab2,...), notes:Notes and
  silent:T, where lab1, lab2, ... and Notes are CHARACTER scalars or
  vectors.



Keywords: variables, combining variables, character variables
                                  Usage
array(x,dimVec) makes an array whose dimensions are the elements of
dimVec, a vector of positive integers.  The data are taken from REAL,
LOGICAL or CHARACTER variable x.  The dimensions of x are ignored, that
is, array(x,dimVec) is equivalent to array(vector(x),dimVec).  For
example, array(run(24),vector(4,3,2)) creates a 4 by 2 by 2 array.

Except when x is a scalar, there must be exactly N elements in x, where
N = product of dimensions.  array() duplicates a scalar N times so, for
example, array(0,2,3,4) is the same as array(rep(0,24),2,3,4).

The data from x are entered with the leftmost dimensions varying fastest
and the rightmost varying slowest.  For example, array(run(20),
vector(5,4)) is equivalent to matrix(run(20),5).

array(x,n1,n2,...) is equivalent to array(x,vector(n1,n2,...)), when n1,
n2, ...  are REAL scalars or vectors.  Most usually n1, n2, ... are
scalars, as in array(run(24),4,3,2) which creates a 4 by 3 by 2 array.

When x is a scalar, vector, matrix or array, array(x), with no
dimensions, is equivalent to array(x,dim(x)), that is, it returns a
variable identical to x, possibly with the addition of coordinate labels
or notes.  See below.

                      Keywords 'labels' and 'notes'
You can specify coordinate labels for the output using keyword phrase
'labels:Labels'.  See topic 'labels' for details.

You can attach a CHARACTER vector Notes of descriptive notes to the
result using keyword phrase 'notes:Notes'.  See topic 'notes' for
details.

When no dimensions are specified or the new dimensions exactly match the
dimensions of x, any coordinate labels or descriptive notes of x are
transferred to the result unless 'labels' or 'notes' provide new labels
or notes or are NULL.

                            Cross references
See also topics matrix(), 'matrices', 'subscripts', 'variables'.


Gary Oehlert 2005-08-12