insert: Insert values to a vector at certain positions

Description Usage Arguments Author(s) Examples

Description

Insert values to a vector at certain positions.

Usage

1
2
## Default S3 method:
insert(x, index, value=NA, ...)

Arguments

x

The vector of data values.

index

The indices where the values should be inserted.

value

The values to be inserted. The values will be looped over if this vector is shorter than the index vector.

...

Not used.

Author(s)

Henrik Bengtsson

Examples

1
2
3
4
5
  vec     <- c(1:10,13:15,19:20)
  missing <- setdiff(1:20, vec)
  vec2 <- insert(vec, missing)
  print(vec2)
  # [1]  1  2  3  4  5  6  7  8  9 10 NA NA 13 14 15 NA NA NA 19 20

HenrikBengtsson/R.basic documentation built on May 6, 2019, 11:51 p.m.