View source: R/str2str_functions.R
ld2a | R Documentation |
ld2a
converts a list of data.frames to a 3D array. The data.frames must
have the same dimensions.
ld2a(
ld,
dim.order = c(1, 2, 3),
dimlab.list = NULL,
fct = "chr",
chr = "chr",
lgl = "int",
order.lvl = "alphanum",
decreasing = FALSE,
na.lvl = FALSE,
check = TRUE
)
ld |
list of data.frames that all have the same dimensions. |
dim.order |
integer vector of length 3 specifying the order of dimensions for
the returned array. The default is |
dimlab.list |
character vector of length 1 specifying the dimlabel for the list dimension. |
fct |
character vector of length 1 specifying what factors should be converted to. There are three options: 1) "chr" for converting to character vectors (i.e., factor labels), 2) "int" for converting to integer vectors (i.e., factor codes), or 3) "fct" for keeping the factor as is without any changes. |
chr |
character vector of length 1 specifying what character vectors should be converted to. There are three options: 1) "fct" for converting to factors (i.e., elements will be factor labels), 2) "int" for converting to integer vectors (i.e., factor codes after first converting to a factor), or 3) "chr" for keeping the character vectors as is without any changes. |
lgl |
character vector of length 1 specifying what logical vectors should be converted to. There are four options: 1) "fct" for converting to factors (i.e., "TRUE" and "FALSE" will be factor labels), 2) "chr" for converting to character vectors (i.e., elements will be "TRUE" and "FALSE"), 3) "int" for converting to integer vectors (i.e., TRUE = 1; FALSE = 0), and 4) "lgl" for keeping the logical vectors as is without any changes. |
order.lvl |
character vector of length 1 specifying how you want to order the levels of the factor. The options are "alphanum", which sorts the levels alphanumerically (with NA last); "position", which sorts the levels by the position the level first appears; "frequency", which sorts the levels by their frequency. If any frequencies are tied, then the ties are sorted alphanumerically (with NA last). |
decreasing |
logical vector of length 1 specifying whether the ordering of the levels should be decreasing (TRUE) rather than increasing (FALSE). |
na.lvl |
logical vector of length 1 specifying if NA should be considered a level. |
check |
logical vector of length 1 specifying whether to check the structure
of the input arguments. For example, check whether |
If the columns of the data.frames in ld
are not all the same typeof, then
the return object is coerced to the most complex type of any data.frame column (e.g.,
character > double > integer > logical). See unlist
for details about
the hierarchy of object types.
3D array with all the elements from ld
organized into dimensions
specified by dim.order
.
ld <- list("first" = BOD, "second" = BOD*2, "third" = BOD*3)
ld2a(ld)
ld <- list("cars" = cars, "mtcars" = mtcars)
try_expr(ld2a(ld)) # error
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.