do_call_rbind: Recursively "rbind" a list of objects, such as _xts_ time...

View source: R/rutils.R

do_call_rbindR Documentation

Recursively ‘rbind’ a list of objects, such as xts time series.

Description

Recursively ‘rbind’ a list of objects, such as xts time series.

Usage

do_call_rbind(listv)

Arguments

listv

A list of objects, such as vectors, matrices, data frames, or time series.

Details

Performs 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.

The function do_call_rbind() performs the same operation as do.call(rbind, listv), but using recursion, which is much faster and uses less memory. This is the same function as ‘do.call.rbind’ from package ‘qmao’.

Value

A single vector, matrix, data frame, or time series.

Examples

# 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))

algoquant/rutils documentation built on April 18, 2024, 12:05 a.m.