Learn R Programming

NCmisc (version 1.2.0)

Dim: A more general dimension function

Description

A more general 'dim' function. For arrays simply calls the dim() function, but for other data types, tries to provide an equivalent, for instance will call length(x) for vectors, and will recursively report dims for lists, and will attempt something sensible for other datatypes.

Usage

Dim(x, cat.lists = TRUE)

Value

dimension(s) of the object

Arguments

x

the object to find the dimension for

cat.lists

logical, for lists, TRUE will concatenate the dimesions to a single string, or FALSE will return the sizes as a list of the same structure as the original.

See Also

prv, preview

Examples

Run this code
# create variables of different types to show output styles #
Dim(193)
Dim(1:10)
testvar <- matrix(rnorm(100),nrow=25)
Dim(matrix(rnorm(100),nrow=25))
Dim(list(first="test",second=testvar,third=100:110))
Dim(list(first="test",second=testvar,third=100:110),FALSE)

Run the code above in your browser using DataLab