insert: Insert values into a vector

View source: R/insert.r

insertR Documentation

Insert values into a vector

Description

This function inserts values into a vector, lengthening the overall vector. It is different from, say, x[1:3] <- c('a', 'b', 'c') which simply replaces the values at indices 1 through 3.

Usage

insert(x, into, at, warn = TRUE)

Arguments

x

Vector of numeric, integer, character, or other values of the class of x to be inserted.

into

Vector of values into which to insert x.

at

Vector of positions (indices) where x should be inserted. If the length of x is shorter than the length of at, then values in x will be recycled and a warning produced.

warn

If TRUE, provide warnings.

Value

Vector.

See Also

insertCol, insertRow

Examples


x <- -1:-3
into <- 10:20
at <- c(1, 3, 14)
insert(x, into, at)

insert(-1, into, at)


omnibus documentation built on Sept. 17, 2024, 5:09 p.m.