v_to_3d: Vector to 3-dim array

Description Usage Arguments Value Examples

View source: R/utility.R

Description

Test whether an input is a vector, and if so, transform it into a array with its second and third dimension lengths equal to 1. If an input is neither a vector nor a 3-dimensional array, returns NULL with an error message.

Usage

1
v_to_3d(v, obj.name)

Arguments

v

a vector or an array

obj.name

a string used to display the error message

Value

a list containing the following components

res.arr

Corresponding 3-dimensional array. If the input is not right, this contains NULL

err.stat

Error status variable, taking 1 if the input it not right. Otherwise, this equals 0.

err.msg

Error message to display if err.stat = 1. This contains an empty string if err.stat = 0.

Examples

1
2
3
v_to_3d(1:10, "omega")
v_to_3d(array(1:10, dim = c(10, 1, 1)), "omega")
v_to_3d(matrix(1:10, ncol = 1), "omega")

koohyun-kwon/HTEBand documentation built on Dec. 21, 2021, 7:42 a.m.