Description Usage Arguments Value Note Author(s) References Examples
While convenient methods exist for converting table
s and other
objects to data.tables
s, such methods do not exist for converting an
ftable
to a data.table
. An ftable
is essentially a matrix
with
attributes
for the rows and columns, which can be nested.
1 | ftable2dt(inarray, direction = "wide")
|
inarray |
The input |
direction |
Should the reslut be "wide" (with multiple measurement.
columns) or "long" (with a single measurement column)? Defaults to |
A data.table
If the array has no dimnames
, names would be added using the
provideDimnames
function. Defaults to reshape2::melt()
if the input is a
simple matrix and not a multidimensional array.
Ananda Mahto
http://stackoverflow.com/a/11143126/1270695
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | x <- ftable(Titanic, row.vars = 1:3)
x
ftable2dt(x)
ftable2dt(x, direction = "long")
## Not run:
dims <- c(2, 1, 2, 3, 2)
set.seed(1)
M <- `dim<-`(sample(100, prod(dims), TRUE), dims)
N <- O <- `dimnames<-`(M, lapply(dims, function(x)
c(letters, LETTERS)[seq_len(x)]))
names(attributes(O)$dimnames) <- c("first", "second", "third",
"fourth", "fifth")
ftable2dt(M)
ftable2dt(N)
ftable2dt(O)
ftable2dt(M, "long")
ftable2dt(N, "long")
ftable2dt(O, "long")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.