Learn R Programming

universals (version 0.0.3)

ndims: Number of Dimensions

Description

Gets the number of dimensions of an object as returned by dims().

The default methods returns the length of dims().

Usage

ndims(x, ...)

# S3 method for default ndims(x, ...)

# S3 method for matrix ndims(x, ...)

# S3 method for data.frame ndims(x, ...)

Arguments

x

An object.

...

Other arguments passed to methods.

Value

A integer scalar of the number of dimensions.

Details

For matrices ndims() is always 2L.

For data frames ndims() is always 2L.

See Also

Other dimensions: dims(), npdims(), pdims()

Examples

Run this code
# NOT RUN {
ndims(character(0))
ndims(1:3)
ndims(matrix(1))
ndims(data.frame())
ndims(array(1:9, dim = c(3,1,3)))
# }

Run the code above in your browser using DataLab