(3D+) Array to Data-Frame
a2d converts a (3D+ array) to a data.frame. It allows you to specify a
dimension of the array to be the columns. All other dimensions are variables
in the data.frame. This is different than as.data.frame.array which
converts the (3D+) array to a matrix first; although it is very similar to
as.data.frame.table.
a2d(a, col = 0, stringsAsFactors = FALSE, check = TRUE)
a |
3D+ array. |
col |
integer vector or character vector of length 1 specifing the dimension
of |
stringsAsFactors |
logical vector of length 1 specifying whether the variable dimensions should be factors of chracter vectors. |
check |
logical vector of length 1 specifying whether to check the structure
of the input arguments. For example, check whether |
a2d is mostly a wrapper for reshape::melt.array (+ reshape::cast)
that allows for the variable dimensions to be character vectors rather than factors.
data.frame of a's elements. The colnames of the variable dimensions
are the names of the dimensions in a. If there were no dimension names in
a, then each dimension is named after its number with an X in front.
If col is not 0, then the rest of the colnames are the dimnames of
that dimension from a. If col is 0, then the names of the single
column with a's elements is "element".
a2d(HairEyeColor)
a2d(HairEyeColor, col = 1)
a2d(HairEyeColor, col = "Hair", stringsAsFactors = TRUE)
a2d(HairEyeColor, col = 2)
a2d(HairEyeColor, col = "Sex", stringsAsFactors = TRUE)
try_expr(a2d(as.matrix(attitude))) # error due to inputting a matrix. Instead use \code{m2d}.Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.