Gets the dimensions of an object.

dims(x, ...)

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

# S3 method for factor
dims(x, ...)

Arguments

x

An object.

...

Other arguments passed to methods.

Value

An integer vector of the dimensions.

Details

Unlike base::dim(), dims returns the length of an atomic vector.

See also

base::dim()

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

Examples

dims(numeric(0))
#> [1] 0
dims(1:3)
#> [1] 3
dims(factor("a"))
#> [1] 1
dims(matrix(1:4, nrow = 2L))
#> [1] 2 2
dims(array(1:9, dim = c(3L,1L,3L)))
#> [1] 3 1 3
dims(ToothGrowth)
#> [1] 60  3
dims(Titanic)
#> [1] 4 2 2 2