Dim Attribute of an Object

DESCRIPTION:

Returns or changes the dim attribute, which describes the dimensions of a matrix, data frame, bdFrame, or array.

USAGE:

dim(x) 
dim(x) <- value 

REQUIRED ARGUMENTS:

x
any object.

OPTIONAL ARGUMENTS:

value
numeric vector suitable to be the dimensions of x(missing values are not allowed), or NULL.

VALUE:

integer vector of the dimensions of x, if any; and NULL if x does not have dimensions.

SIDE EFFECTS:

assigning to dim(x) establishes or changes the dim attribute of x if it is an array or matrix; no re-ordering of the elements of x is implied. If the object had names (a "names" attribute) they are currently deleted.

DETAILS:

This is a generic function, dim has a method for data frames and bdFrames, which counts the length of the row.names attribute and the number of columns. You may not change the dimensions of a data frame or bdFrame.

Arrays and matrices have a dim attribute which is an integer vector, with the property that prod(dim(x))==length (x). This attribute identifies an object as an array.

SEE ALSO:

, , , , , .

EXAMPLES:

dim(iris) # returns c(50, 4, 3) 
length(dim(y)) # number of dimensions of y 
if(!is.null(dim(z))) { .. z .. } # do not operate on non-array data 
if(is.array(z)) { .. z .. } # better way to do the same thing