Coerce an Array into a Data Frame Object

USAGE:

as.data.frame.array(x, row.names = NULL, optional = FALSE, 
                    col.dims = length(dim(x)), row.dims, index.dims) 

ARGUMENTS:

x
an array to be coerced to a data frame
row.names
optional row names of the result
optional
flag to allow name omission. See as.data.frame.
col.dims
vector indicating dimensions of x to unfold to columns of the returned data.frame. Remaining dimensions unfold to rows. Character, numeric, or logical vectors are interpreted as in subsetting the dimnames of x with [].
row.dims
alternative to col.dims. Vector of dimensions to unfold to rows. At most one of col.dims and row.dims should be supplied.
index.dims
optional vector indicating dimensions of x for which index variables should be produced. Dimensions in col.dims (or not in row.dims ) are ignored. By default index variables are produced only when more than one dimension unfolds to rows and in this case all index variables are returned.

VALUE:

x is converted to a data frame with as many rows as the product of the dimensions indicated by row.dims (or the complement of col.dims ). The data in x is placed in variables created to code the col.dim dimensions. Index variables are created for dimensions unfolded to rows according to index.dims. The default behavior creates a variable for each level in the last dimension of x. Remaining dimensions are unfolded to rows. Factors with indexing information are returned if 2 or more dimensions unfold to rows. Thus, the default behavior matches as.data.frame.matrix for 2 dimensional arrays.

EXAMPLES:

names(dimnames(iris)) <- c("flower","measurement","species") 
as.data.frame.array(iris, col.dims = 2) 
as.data.frame.array(iris, col.dims = "measurement") 
        # two ways to get a variable for each  
        # "measurement" type (dimension 2) 
as.data.frame.array(iris)  
        # a variable for each "species" (= last dimension, default)