sdim() prints the name and dimensions of list object elements,
such as a list of data.frame
ssdim() prints the name and dimensions of nested elements of list
objects, for example a list of list objects that each contain
other objects.
sdima() prints the name and dimensions of object attributes(x).
It is useful for summarizing the attributes() of an object.
ssdima() prints the name and dimensions of nested elements of list
object attributes(), for example a list of list objects that each
contain other objects. It is useful for comparing attributes across list
elements.
This function prints the dimensions of a list of objects, usually a list
of data.frame objects, but extended to handle more complicated lists,
including even S4 object methods::slotNames().
Over time, more object types will be made compatible with this function.
Currently, igraph objects will print the number of nodes and edges, but
requires the igraph package to be installed.
Usage
sdim(
x,
includeClass = TRUE,
doFormat = FALSE,
big.mark = ",",
verbose = FALSE,
...
)
sdima(
x,
includeClass = TRUE,
doFormat = FALSE,
big.mark = ",",
verbose = FALSE,
...
)
ssdima(
x,
includeClass = TRUE,
doFormat = FALSE,
big.mark = ",",
verbose = FALSE,
...
)
ssdim(
x,
includeClass = TRUE,
doFormat = FALSE,
big.mark = ",",
verbose = FALSE,
...
)Arguments
- x
one of several recognized object classes:
an S3 object inheriting from class
"list", including a nested list of lists or simple listan S3 atomic object, which returns only the length
a single multi-dimensional object such as
data.frame,matrix,array,tibble, or similar, which returns only its dimensions.an
S4object in which case it usedmethods::slotNames(x)to traverse the object structurean
"environment"object, in which casels(envir=x)is used to traverse the object structure.When the object is
S4that inherits"List"from theS4Vectorspackage, it will attempt to use the proper subset functions fromS4Vectorsvianames(x), but that process only works properly if theS4Vectorspackage is previously loaded, otherwise it reverts to usingmethods::slotNames(x).
- includeClass
logicalindicating whether to print the class of each element in the inputxobject. Note that for S4 objects, each element will be the object returned for each ofmethods::slotNames(x).- doFormat
logicalindicating whether to format the dimensions usingformat(...,big.mark=","), which is mainly useful for extremely large dimensions. This parameter should probably become more broadly useful and respectful for different locales.- big.mark
charactervalue used whendoFormat=TRUE, used in the call toformat(...,big.mark).- verbose
logicalwhether to print verbose output- ...
additional parameters are ignored.
Value
data.frame where each row indicates the dimensions of
each element in the input list. When includeClass is TRUE it
will include a column class which indicates the class of each
list element. When the input list contains arrays with more than
two dimensions, the first two dimensions are named "rows" and
"columns" with additional dimensions named "dim3" and so on.
Any list element with fewer than that many dimensions will only have
values populated to the relevant dimensions, for example a character
vector will only populate the length.
data.frame which
describes the dimensions of the objects in
attributes(x).
list of data.frame each of which
describes the dimensions of the objects in
attributes(x).
list of data.frame, each row indicates the dimensions of
each element in the input list.
When includeClass is TRUE it
will include a column class which indicates the class of each
list element.
When the input list contains arrays with more than
two dimensions, the first two dimensions are named "rows" and
"columns" with additional dimensions named "dim3" and so on.
Any list element with fewer than that many dimensions will only have
values populated to the relevant dimensions, for example a character
vector will only populate the length.
See also
Other jam list functions:
cPaste(),
heads(),
jam_rapply(),
list2df(),
mergeAllXY(),
mixedSorts(),
rbindList(),
relist_named(),
rlengths(),
sclass(),
uniques(),
unnestList()
Examples
L <- list(LETTERS=LETTERS,
letters=letters,
lettersDF=data.frame(LETTERS, letters));
sdim(L)
#> rows cols class
#> LETTERS 26 character
#> letters 26 character
#> lettersDF 26 2 data.frame
LL <- list(L=L, A=list(1:10))
sdim(LL)
#> rows class
#> L 3 list
#> A 1 list
ssdim(LL)
#> $L
#> rows cols class
#> LETTERS 26 character
#> letters 26 character
#> lettersDF 26 2 data.frame
#>
#> $A
#> rows class
#> 1 10 integer
#>
m <- matrix(1:9,
ncol=3,
dimnames=list(
Rows=letters[1:3],
Columns=LETTERS[1:3]));
sdima(m);
#> rows class
#> dim 2 integer
#> dimnames 2 list
ssdima(m);
#> $dim
#> rows class
#> 1 2 integer
#>
#> $dimnames
#> rows class
#> Rows 3 character
#> Columns 3 character
#>