Learn R Programming

clustComp (version 1.0.0)

insert: Insert a set of values at a given position of a vector

Description

insert introduces a vector at a given position of another vector, displacing to the right all values from that position onwards.

Usage

insert(vect, position, value)

Arguments

vect
the vector in which to insert additional values.
position
the position of vector vect at which to insert additional values.
value
the values to be inserted in the vector vect.

Value

new.vector
the vector resulting after inserting value at the position determined by position.

Details

The value of position does not need to be a number smaller than or equal to the length of vect, as the missing values will be denoted as NA.

Examples

Run this code
    # simulated data
    v1 <- 1:10
    v2 <- insert(v1, 4, 0)
    v2 <- insert(v1, 1, rep(0, 5))
    v2 <- insert(v1, 11, "A")
    v2 <- insert(v1, 12, "A")

Run the code above in your browser using DataLab