append
Insert or Merge Data

Description

Adds to or replaces elements of a vector.

Usage

append(x, values, after = length(x))
replace(x, list, values)

Arguments

x a vector of data to be edited. Missing values (NAs) are allowed.
list a vector of the indices of the elements in x to be replaced.
values a vector of values to replace the list of elements, or to be appended after the after position. If values is shorter than list, it is re-used cyclically. If values is shorter than list, a warning is given. Missing values (NAs) are allowed.
after an index in x after which values is appended. If after = 0, values is placed at the beginning. Any negative value of after causes an error.
Value
returns the edited vector to be assigned back to x, or to be used in any other way. Unless the result is assigned back to x, x is not changed.
See Also
c
Examples
x <- 1:10
# replace x[3] with 1.5
x <- replace(x,3,1.5)
# alternative: replaces x[3] with 1.5
x[3]<-1.5
# append two values in x[7],x[8]
x <- append(x,c(3.4,5.7),6)
# replace the four elements with 0
y <- replace(x,c(3,7,8,9),0)
Package base version 6.0.0-69
Package Index