do_call | R Documentation |
Performs a similar operation as do.call()
, but using recursion, which
is much faster and uses less memory. The function do_call()
is a
generalization of function do_call_rbind()
.
do_call(func, listv, ...)
func |
The name of function that returns a single object from a list of objects. |
listv |
A list of objects, such as vectors, matrices, data frames, or time series. |
... |
Additional arguments to function |
The function do_call()
performs an lapply loop, each time
binding neighboring elements and dividing the length of listv
by
half. The result of performing do_call(rbind, list_xts)
on a list of
xts time series is identical to performing do.call(rbind,
list_xts)
. But do.call(rbind, list_xts)
is very slow, and often
causes an ‘out of memory’ error.
A single vector, matrix, data frame, or time series.
# Create xts time series
xtsv <- xts(x=rnorm(1000), order.by=(Sys.time()-3600*(1:1000)))
# Split time series into daily list
list_xts <- split(xtsv, "days")
# rbind the list back into a time series and compare with the original
identical(xtsv, rutils::do_call(rbind, list_xts))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.