insert_after | R Documentation |
It is often helpful to insert an item into a list
after another known item rather than at an index of the list as base::append()
does.
This function provides that functionality.
insert_after(
x,
after = NULL,
values,
.after_all = TRUE,
.equals_function = `==`
)
x |
a list into which |
after |
the object in |
values |
the object to be inserted into |
.after_all |
a boolean telling whether to insert |
.equals_function |
insertion of |
If there are multiple copies of after
in x
,
values
is inserted after each after
, unless .after_all = FALSE
.
The positions at which insertions will occur are determined by the ==
operator.
I.e., values
are inserted in x
after each position in x
where x == after
is true.
Note that length(after)
must be 1.
If is.null(after)
, values
is inserted once at the end of the list.
a modified version of x
insert_after(list("a", "b", "c", "d", "c"), after = "c", values = "1")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.