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

Description Usage Arguments Details Value Examples

View source: R/rutils.R

Description

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

Usage

1

Arguments

li_st

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 li_st 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, li_st), 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

1
2
3
4
5
6
# Create xts time series
x_ts <- xts(x=rnorm(1000), order.by=(Sys.time()-3600*(1:1000)))
# Split time series into daily list
list_xts <- split(x_ts, "days")
# rbind the list back into a time series and compare with the original
identical(x_ts, rutils::do_call_rbind(list_xts))

algoquant/rutils documentation built on Feb. 26, 2021, 1:30 a.m.