Learn R Programming

textutils (version 0.4-1)

insert: Vector Insertion

Description

Insert elements into a vector.

Usage

insert(x, values, before.index)

Value

A vector with values inserted. If either

values or before.index are of length zero, the original vector is returned.

Arguments

x

a vector

values

elements to insert

before.index

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

Author

Enrico Schumann

Details

Inserts elements into a vector.

See Also

Examples

Run this code
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"

Run the code above in your browser using DataLab