Inserts new values into a vector at specified positions
This function inserts new values at specified positions in a vector. It does not replace existing values. If a single value is provided for y and l represents multiple positions y will be replicated for the length of l. In this way you can insert the same value at multiple locations.
insert.values(x, value, index)
x | A vector to insert values |
---|---|
value | Values to insert into x |
index | Index position(s) to insert y values into x |
A vector with values of y inserted into x and the position(s) defined by the index
Jeffrey S. Evans <jeffrey_evans@tnc.org>
(x=1:10)#> [1] 1 2 3 4 5 6 7 8 9 10# Insert single value in one location insert.values(x, 100, 2)#> [1] 1 100 2 3 4 5 6 7 8 9 10#> [1] 1 100 2 3 4 5 6 200 7 8 9 10#> [1] 1 NA 2 3 4 5 6 NA 7 8 9 10