dim(x), x a scalar, vector, matrix, array, structure, macro or GRAPH variable. |

dim(x) returns a vector containing the dimensions of x. For example, when x is a vector of length 10, dim(x) has value 10. When x is a 5 by 7 matrix, dim(x) has value vector(5,7) and dim(x)[1] and dim(x)[2] are 5 and 7, respectively. When x is an array with k dimensions, dim(x) is a vector of length k. When x is a macro or GRAPH variable, dim(x) is 1. When x is a NULL variable, dim(x) is 0. This is a change from version 4.07 and earlier when dim(NULL) was NULL. When x is a structure, dim(x) is a structure, each of whose components is a structure with the same shape as x. Suppose N is the largest number of dimensions of any component of x or is 1 if all non-structure components of x are NULL. Then dim(x) has N components named 'dim1', 'dim2', .... When xcomp is a non-NULL and non-structure component of x, the corresponding component of dim(x)[j], that is, x$dimj, is dim(xcomp)[j] when ndims(xcomp) <= j or 0 when ndims(xcomp) < j. When xcomp is NULL, the corresponding component of dim(x)[j] is 0. Examples: dim(4) is 1 dim(run(6)) is 6 dim(matrix(run(20),5)) is vector(5,4) dim(array(run(24),2,3,4)) is vector(2,3,4) dim(structure(run(6),structure(matrix(run(6),3),NULL)) is structure(dim1:structure(6,structure(3,0)), dim2:structure(0,structure(2,0))) See also topics length(), ndims(), 'structures', 'NULL'.

Gary Oehlert 2003-01-15