trimmers: Trim vector by index

trimmersR Documentation

Trim vector by index

Description

Trim vector by index

Trim vector front ⁠%[-%⁠

Trim vector rear ⁠%-]%⁠

Trim vector front + rear ⁠%[-]%⁠

Usage

x %[-% i

x %-]% i

x %[-]% j

Arguments

x

A vector

i

A 1 element vector by which the rear of x will be trimmed

j

A one, or two element numeric vector. One element: Trim front by floor(i/2) and rear by ceiling(i/2). Two elements: Trim i[1] from the front and i[2] from the rear.

Value

A trimmed version of x

Examples


x <- rnorm(100)

# Trim front
x%[-%5

# Trim rear
x%-]%5

# Trim front + rear
x%[-]%c(2,10)

x%[-]%7


FredHasselman/invctr documentation built on Feb. 19, 2025, 5:12 a.m.