dimdim {FatTailsR} | R Documentation |
Length and Dimensions of Vector, Matrix, Array, Data.Frame, List
Description
Dimensions and length of vector, matrix, array, data.frame and list.
A friendly version of dim
that returns the true dimension
rather than the sometimes unexpected NULL
value.
The number of dimensions appears first, then the length in each dimension.
A special case is list: the list's length (number of items) is turned into a
negative integer and the dimension/length of each item is either positive
if the item is a vector, matrix, array or data.frame or negative if the item
is itself a list. Only the first level of the list is explored.
dimdim1
and dimdimc
return the first item of dimdim
,
thus the true dimension, either as an integer or as a character
and, in this latest case, always "-1"
for lists.
Notes: From version 1.6.2 (April 2016), dimdim(NULL) = c(0, 0)
.
(before c(1, 0)
). Hence, dimdim1(NULL) = 0
and
dimdimc(NULL) = "0"
.
Some problems may occur with S4 objects like
dimdim(qualityTools::fracDesign(k = 3, gen = "C = AB"))
.
Usage
dimdim(x)
dimdim1(x)
dimdimc(x)
Arguments
x |
vector, matrix, array, data.frame, list. |
Examples
require(timeSeries)
dimdim(NULL)
dimdim(NA); dimdim(NaN); dimdim(Inf); dimdim(TRUE); dimdim(FALSE)
dimdim(11:39)
dimdim(LETTERS[1:8])
dimdim(matrix(1:60, ncol=5))
dimdim(extractData())
dimdim(as.data.frame(extractData()))
dimdim(data.frame(X=1:2, Y=1:4, Z=LETTERS[1:8]))
dimdim(array(1:240, c(8,6,5)))
dimdim(array(1:240, c(4,2,6,5)))
dimdim(getDSdata())
dimdim(zData)
dimdim(xData)
dimdim(tData)
dimdim1(matrix(1:60, ncol=5))
dimdimc(matrix(1:60, ncol=5))
dimdim1(tData)
dimdimc(tData)