slide_index2 | R Documentation |
slide_index2()
and pslide_index()
represent the combination
of slide2()
and pslide()
with slide_index()
, allowing you to iterate
over multiple vectors at once relative to an .i
-ndex.
slide_index2(.x, .y, .i, .f, ..., .before = 0L, .after = 0L, .complete = FALSE)
slide_index2_vec(
.x,
.y,
.i,
.f,
...,
.before = 0L,
.after = 0L,
.complete = FALSE,
.ptype = NULL
)
slide_index2_dbl(
.x,
.y,
.i,
.f,
...,
.before = 0L,
.after = 0L,
.complete = FALSE
)
slide_index2_int(
.x,
.y,
.i,
.f,
...,
.before = 0L,
.after = 0L,
.complete = FALSE
)
slide_index2_lgl(
.x,
.y,
.i,
.f,
...,
.before = 0L,
.after = 0L,
.complete = FALSE
)
slide_index2_chr(
.x,
.y,
.i,
.f,
...,
.before = 0L,
.after = 0L,
.complete = FALSE
)
slide_index2_dfr(
.x,
.y,
.i,
.f,
...,
.before = 0L,
.after = 0L,
.complete = FALSE,
.names_to = rlang::zap(),
.name_repair = c("unique", "universal", "check_unique")
)
slide_index2_dfc(
.x,
.y,
.i,
.f,
...,
.before = 0L,
.after = 0L,
.complete = FALSE,
.size = NULL,
.name_repair = c("unique", "universal", "check_unique", "minimal")
)
pslide_index(.l, .i, .f, ..., .before = 0L, .after = 0L, .complete = FALSE)
pslide_index_vec(
.l,
.i,
.f,
...,
.before = 0L,
.after = 0L,
.complete = FALSE,
.ptype = NULL
)
pslide_index_dbl(.l, .i, .f, ..., .before = 0L, .after = 0L, .complete = FALSE)
pslide_index_int(.l, .i, .f, ..., .before = 0L, .after = 0L, .complete = FALSE)
pslide_index_lgl(.l, .i, .f, ..., .before = 0L, .after = 0L, .complete = FALSE)
pslide_index_chr(.l, .i, .f, ..., .before = 0L, .after = 0L, .complete = FALSE)
pslide_index_dfr(
.l,
.i,
.f,
...,
.before = 0L,
.after = 0L,
.complete = FALSE,
.names_to = rlang::zap(),
.name_repair = c("unique", "universal", "check_unique")
)
pslide_index_dfc(
.l,
.i,
.f,
...,
.before = 0L,
.after = 0L,
.complete = FALSE,
.size = NULL,
.name_repair = c("unique", "universal", "check_unique", "minimal")
)
.x , .y |
Vectors to iterate over. Vectors of size 1 will be recycled. |
.i |
The index vector that determines the window sizes. It is fairly common to supply a date vector as the index, but not required. There are 3 restrictions on the index:
|
.f |
If a function, it is used as is. If a formula, e.g.
This syntax allows you to create very compact anonymous functions. |
... |
Additional arguments passed on to the mapped function. |
.before , .after |
The ranges that result from applying |
.complete |
Should the function be evaluated on complete windows only? If |
.ptype |
A prototype corresponding to the type of the output. If If supplied, the result of each call to If |
.names_to |
This controls what to do with input names supplied in
|
.name_repair |
One of With |
.size |
If, Alternatively, specify the desired number of rows, and any inputs of length 1 will be recycled appropriately. |
.l |
A list of vectors. The length of |
A vector fulfilling the following invariants:
slide_index2()
vec_size(slide_index2(.x, .y)) == vec_size_common(.x, .y)
vec_ptype(slide_index2(.x, .y)) == list()
slide_index2_vec()
and slide_index2_*()
variantsvec_size(slide_index2_vec(.x, .y)) == vec_size_common(.x, .y)
vec_size(slide_index2_vec(.x, .y)[[1]]) == 1L
vec_ptype(slide_index2_vec(.x, .y, .ptype = ptype)) == ptype
pslide_index()
vec_size(pslide_index(.l)) == vec_size_common(!!! .l)
vec_ptype(pslide_index(.l)) == list()
pslide_index_vec()
and pslide_index_*()
variantsvec_size(pslide_index_vec(.l)) == vec_size_common(!!! .l)
vec_size(pslide_index_vec(.l)[[1]]) == 1L
vec_ptype(pslide_index_vec(.l, .ptype = ptype)) == ptype
slide2()
, hop_index2()
, slide_index()
# Notice that `i` is an irregular index!
x <- 1:5
y <- 6:10
i <- as.Date("2019-08-15") + c(0:1, 4, 6, 7)
# When we slide over `i` looking back 1 day, the irregularity is respected.
# When there is a gap in dates, only 2 values are returned (one from
# `x` and one from `y`), otherwise, 4 values are returned.
slide_index2(x, y, i, ~c(.x, .y), .before = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.