tile2.Rd
Tiling window without overlapping observations:
tile2()
and ptile()
always returns a list.
tile2_lgl()
, tile2_int()
, tile2_dbl()
, tile2_chr()
use the same
arguments as tile2()
, but return vectors of the corresponding type.
tile2_dfr()
tile2_dfc()
return data frames using row-binding & column-binding.
tile2(.x, .y, .f, ..., .size = 1, .bind = FALSE) tile2_dfr(.x, .y, .f, ..., .size = 1, .bind = FALSE, .id = NULL) tile2_dfc(.x, .y, .f, ..., .size = 1, .bind = FALSE) ptile(.l, .f, ..., .size = 1, .bind = FALSE) ptile_dfr(.l, .f, ..., .size = 1, .bind = FALSE, .id = NULL) ptile_dfc(.l, .f, ..., .size = 1, .bind = FALSE)
.x | Objects to slide over simultaneously. |
---|---|
.y | Objects to slide over simultaneously. |
.f | A function, formula, or vector (not necessarily atomic). If a function, it is used as is. If a formula, e.g.
This syntax allows you to create very compact anonymous functions. If character vector, numeric vector, or list, it is
converted to an extractor function. Character vectors index by
name and numeric vectors index by position; use a list to index
by position and name at different levels. If a component is not
present, the value of |
... | Additional arguments passed on to the mapped function. |
.size | An integer for window size. If positive, moving forward from left to right; if negative, moving backward (from right to left). |
.bind | If |
.id | Either a string or Only applies to |
.l | A list of vectors, such as a data frame. The length of |
Other tiling window functions: tile
x <- 1:5 y <- 6:10 z <- 11:15 lst <- list(x = x, y = y, z = z) df <- as.data.frame(lst) tile2(x, y, sum, .size = 2)#> [[1]] #> [1] 16 #> #> [[2]] #> [1] 24 #> #> [[3]] #> [1] 15 #>tile2(lst, lst, ~ ., .size = 2)#> [[1]] #> [[1]]$x #> [1] 1 2 3 4 5 #> #> [[1]]$y #> [1] 6 7 8 9 10 #> #> #> [[2]] #> [[2]]$z #> [1] 11 12 13 14 15 #> #>tile2(df, df, ~ ., .size = 2)#> [[1]] #> x y z #> 1 1 6 11 #> 2 2 7 12 #> #> [[2]] #> x y z #> 3 3 8 13 #> 4 4 9 14 #> #> [[3]] #> x y z #> 5 5 10 15 #>ptile(lst, sum, .size = 1)#> [[1]] #> [1] 18 #> #> [[2]] #> [1] 21 #> #> [[3]] #> [1] 24 #> #> [[4]] #> [1] 27 #> #> [[5]] #> [1] 30 #>#> [[1]] #> [[1]]$x #> [1] 1 2 3 4 5 #> #> [[1]]$y #> [1] 6 7 8 9 10 #> #> #> [[2]] #> [[2]]$z #> [1] 11 12 13 14 15 #> #>