Description Usage Arguments Examples
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.
1 2 3 |
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 |
1 2 3 4 5 6 7 8 9 10 | 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"
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.