Skip to contents

Enlarge a vector to the given length, filling with given element

Usage

enlargeVector(x, length.out, fill.with = "")

Arguments

x

vector

length.out

desired length of output vector

fill.with

element to fill the vector up with (default: "")

Value

x, filled up with fill.with to a final length of

length.out

Examples

kwb.utils::enlargeVector(1:5, 10, fill.with = 0) 
#>  [1] 1 2 3 4 5 0 0 0 0 0
kwb.utils::enlargeVector(1:5, 10, fill.with = NA) 
#>  [1]  1  2  3  4  5 NA NA NA NA NA
kwb.utils::enlargeVector(c("a", "b", "c"), 10) 
#>  [1] "a" "b" "c" ""  ""  ""  ""  ""  ""  "" 
kwb.utils::enlargeVector(c("a", "b", "c"), 10, fill.with = "?")
#>  [1] "a" "b" "c" "?" "?" "?" "?" "?" "?" "?"