Replacement and insertion functions with more/less than 1 replacement per spot
multirep
is like replace
, but the replacements are a list of the same length as the number of elements to replace. Each element of the list can have 0, 1, or more elements– the original vector will be expanded/contracted accordingly. (If all elements of the list have length 1, the result will be the same length as the original.) multinsert
is similar, but doesn't overwrite the elements in orig
(so the result of multinsert
is longer). massrep
is like multirep
, but takes lists as arguments so that a group-of-line-numbers in the first list is replaced by a group-of-lines in the second list.
multirep( orig, at, repl, sorted.at=TRUE) multinsert( orig, at, ins, sorted.at=TRUE) massrep( orig, atlist, replist, sorted.at=TRUE)
orig |
vector |
at |
numeric vector, saying which elements of the original will be replaced or appended-to. Can't exceed |
atlist |
list where each element is a group of line numbers to be replaced by the corresponding element of |
repl, ins, replist |
a list of replacements. |
sorted.at |
if TRUE, then |
multirep( cq( the, cat, sat, on, the, mat), c( 2, 6), list( cq( big, bug), cq( elephant, howdah, cushion))) # [1] "the" "big" "bug" "sat" "on" "the" "elephant" "howdah" "cushion" multirep( cq( the, cat, sat, on, the, mat), c( 2, 6), list( cq( big, bug), character(0))) # [1] "the" "big" "bug" "sat" "on" "the" # NB the 0 in next example: multinsert( cq( cat, sat, on, mat), c( 0, 4), list( cq( fat), cq( cleaning, equipment))) # [1] "fat" "cat" "sat" "on" "mat" "cleaning" "equipment"
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.