
Last chance! 50% off unlimited learning
Sale ends in
Fixing an initial window and expanding more observations:
stretch2()
and pstretch()
always returns a list.
stretch2_lgl()
, stretch2_int()
, stretch2_dbl()
, stretch2_chr()
use the same
arguments as stretch2()
, but return vectors of the corresponding type.
stretch2_dfr()
stretch2_dfc()
return data frames using row-binding & column-binding.
stretch2(.x, .y, .f, ..., .size = 1, .init = 1)stretch2_dfr(.x, .y, .f, ..., .size = 1, .init = 1, .id = NULL)
stretch2_dfc(.x, .y, .f, ..., .size = 1, .init = 1)
pstretch(.l, .f, ..., .size = 1, .init = 1)
pstretch_dfr(.l, .f, ..., .size = 1, .init = 1, .id = NULL)
pstretch_dfc(.l, .f, ..., .size = 1, .init = 1)
Objects to slide over simultaneously.
Objects to slide over simultaneously.
A function, formula, or atomic vector.
If a function, it is used as is.
If a formula, e.g. ~ .x + 2
, it is converted to a function. There
are three ways to refer to the arguments:
For a single argument function, use .
For a two argument function, use .x
and .y
For more arguments, use ..1
, ..2
, ..3
etc
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. Within a list, wrap strings in get-attr()
to extract named attributes. If a component is not present, the value of
.default
will be returned.
Additional arguments passed on to .f
.
An integer for moving and initial window size.
If not NULL
a variable with this name will be created
giving either the name or the index of the data frame.
A list of lists. The length of .l
determines the
number of arguments that .f
will be called with. List
names will be used if present.
# NOT RUN {
.x <- 1:5
.y <- 6:10
.z <- 11:15
.lst <- list(x = .x, y = .y, z = .z)
.df <- as.data.frame(.lst)
stretch2(.x, .y, sum, .size = 2)
stretch2(.lst, .lst, ~ ., .size = 2)
stretch2(.df, .df, ~ ., .size = 2)
pstretch(.lst, sum, size = 1)
pstretch(list(.lst, .lst), ~ ., .size = 2)
# }
Run the code above in your browser using DataLab