i_window | R Documentation |
Each element returned by i_window(obj)
consists of n
consecutive
elements from the underlying obj
, with the window advancing
forward by one element each iteration.
i_window(obj, n, tail, ...)
obj |
An iterable. |
n |
The width of the window to apply |
tail |
If a value is given, tails will be included at the beginning and end of iteration, filled with the given value. |
... |
passed along to |
an iteror.
Peter Meilstrup
#' @examples
it <- i_window(iteror(letters[1:4]), 2)
nextOr(it, NA) # list("a", "b")
nextOr(it, NA) # list("b", "c")
nextOr(it, NA) # list("c", "d")
it2 <- i_window(icount(5), 2)
nextOr(it2, NA) # list(1, 2)
nextOr(it2, NA) # list(2, 3)
nextOr(it2, NA) # list(3, 4)
nextOr(it2, NA) # list(4, 5)
it <- i_window(letters[1:4], 2)
nextOr(it, NA) # list("a", "b")
nextOr(it, NA) # list("b", "c")
nextOr(it, NA) # list("c", "d")
it <- i_window(letters[1:4], 3)
nextOr(it) # list("a", "b", "c")
nextOr(it) # list("b", "c", "d")
it <- i_window(letters[1:4], 3, tail=" ")
nextOr(it) # list(" ", " ", "a")
nextOr(it) # list(" ", "a", "b")
nextOr(it) # list("a", "b", "c")
nextOr(it) # list("b", "c", "d")
nextOr(it) # list("c", "d", " ")
nextOr(it) # list("d", " ", " ")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.