Skip to contents

Ensure that the input has at least two dimensions.

Usage

atleast_2d(x)

Arguments

x

An appropriate R object supported by dim(), for example a vector, matrix, array, or data.frame.

Value

The same object, but with a "dim" attribute.

Examples

x <- 1:10
x
#>  [1]  1  2  3  4  5  6  7  8  9 10
atleast_2d(x)
#>       [,1]
#>  [1,]    1
#>  [2,]    2
#>  [3,]    3
#>  [4,]    4
#>  [5,]    5
#>  [6,]    6
#>  [7,]    7
#>  [8,]    8
#>  [9,]    9
#> [10,]   10