View source: R/expected_event.R
fastlag | R Documentation |
Fast replacement of dplyr::lag
for the simple case of n = 1L
and always supplying a new value to insert at the beginning of the vector.
fastlag(x, first)
x |
A vector ( |
first |
A single value ( |
Important: this function is fast because it provides minimal safety checks.
It relies on the
coercion
rules of c
. For best results, x
and first
should be the same type of atomic vector, though it should be fine to mix
numeric
and integer
vectors as long as your own code also
doesn't rely on this distinction. It can also work on lists if needed.
a vector that begins with first
and is followed by x
with its final value removed
gsDesign2:::fastlag(1:5, first = 100) == c(100, 1:4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.