| hop2 {slider} | R Documentation |
Hop along multiple inputs simultaneously
Description
hop2() and phop() represent the combination
of slide2() and pslide() with hop(), allowing you to iterate
over multiple vectors at once, hopping along them using boundaries defined
by .starts and .stops.
Usage
hop2(.x, .y, .starts, .stops, .f, ...)
hop2_vec(.x, .y, .starts, .stops, .f, ..., .ptype = NULL)
phop(.l, .starts, .stops, .f, ...)
phop_vec(.l, .starts, .stops, .f, ..., .ptype = NULL)
Arguments
.x, .y |
Vectors to iterate over. Vectors of size 1 will be recycled. |
.starts, .stops |
Vectors of boundary locations that make up the windows to bucket |
.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. |
.ptype |
A prototype corresponding to the type of the output. If If supplied, the result of each call to If |
.l |
A list of vectors. The length of |
Value
A vector fulfilling the following invariants:
hop2()
-
vec_size(hop2(.x, .y, .starts, .stops)) == vec_size_common(.starts, .stops) -
vec_ptype(hop2(.x, .y, .starts, .stops)) == list()
hop2_vec()
-
vec_size(hop2_vec(.x, .y, .starts, .stops)) == vec_size_common(.starts, .stops) -
vec_size(hop2_vec(.x, .y, .starts, .stops)[[1]]) == 1L -
vec_ptype(hop2_vec(.x, .y, .starts, .stops, .ptype = ptype)) == ptype
phop()
-
vec_size(phop(.l, .starts, .stops)) == vec_size_common(.starts, .stops) -
vec_ptype(phop(.l, .starts, .stops)) == list()
phop_vec()
-
vec_size(phop_vec(.l, .starts, .stops)) == vec_size_common(.starts, .stops) -
vec_size(phop_vec(.l, .starts, .stops)[[1]]) == 1L -
vec_ptype(phop_vec(.l, .starts, .stops, .ptype = ptype)) == ptype
See Also
Examples
hop2(1:2, 3:4, .starts = 1, .stops = c(2, 1), ~c(x = .x, y = .y))
phop(
list(1, 2:4, 5:7),
.starts = c(0, 1),
.stops = c(2, 4),
~c(x = ..1, y = ..2, z = ..3)
)