insert: Vector Insertion

View source: R/functions.R

insertR Documentation

Vector Insertion

Description

Insert elements into a vector.

Usage

insert(x, values, before.index)

Arguments

x

a vector

values

elements to insert

before.index

numeric: before which positions of the original vector to insert the new elements

Details

Inserts elements into a vector.

Value

A vector with values inserted. If either values or before.index are of length zero, the original vector is returned.

Author(s)

Enrico Schumann

See Also

append

Examples

x <- letters[1:5]
## [1] "a" "b" "c" "d" "e"
insert(x, values = "Z", c(2, 5))
## [1] "a" "Z" "b" "c" "d" "Z" "e"

textutils documentation built on May 29, 2024, 10:37 a.m.