padders: Padd vector by index

paddersR Documentation

Padd vector by index

Description

Padd vector by index

Pad vector front

Pad vector rear

Pad vector front + rear

Usage

x %[+% j

x %+]% j

x %[+]% j

Arguments

x

A vector

j

A one, or two element vector. One element: Pad front or rear by j 0s, or, front by floor(j/2) and rear by ceiling(j/2). Two elements: Pad j[1] times the value passed in j[2].

Value

A padded version of x

Examples


x <- rnorm(100)

# Pad front with 10 zeros
x%[+%10
# Same as
x%[+%c(10,0)

# Pad rear with zeros
x%+]%10
# Same as
x%+]%c(10,0)

# Pad front + rear with NA
x%[+]%c(NA,10)

# Pad front + rear of a character vector
"yes"%[+]%c(2,"no")
"yes"%[+]%c(1,"no")
"yes"%[+]%c(0,"no")


invctr documentation built on Aug. 16, 2022, 5:18 p.m.