Skip to contents

This function initializes a vector based on a specified type and size, with an optional initial value.

Usage

initV(typeFunc, x, initVal = NULL)

Arguments

typeFunc

A character string indicating the type of the vector or a function to create the vector.

x

The length of the vector.

initVal

An optional initial value to fill the vector.

Value

A vector of the specified type and size, optionally initialized with a value.

Examples

# Create a numeric vector of length 5
initV("numeric", 5)
#> [1] 0 0 0 0 0
# Create a logical vector of length 3 initialized with TRUE
initV("logical", 3, TRUE)
#> [1] TRUE TRUE TRUE