do_call_assign: Apply a function to a list of objects, merge the outputs into...

View source: R/rutils.R

do_call_assignR Documentation

Apply a function to a list of objects, merge the outputs into a single object, and assign the object to the output environment.

Description

Apply a function to a list of objects, merge the outputs into a single object, and assign the object to the output environment.

Usage

do_call_assign(
  func,
  symbolv = NULL,
  outv,
  inenv = .GlobalEnv,
  outenv = .GlobalEnv,
  ...
)

Arguments

func

The name of a function that returns a single object (vector, xts time series, etc.)

symbolv

A vector of character strings with the names of input objects.

outv

The string with name of output object.

inenv

The environment containing the input symbolv.

outenv

The environment for creating the outv.

...

Additional arguments to function func().

Details

The function do_call_assign() performs an lapply loop over symbolv, applies the function func(), merges the outputs into a single object, and creates the object in the environment outenv. The output object is created as a side effect, while its name is returned invisibly.

Value

A single object (matrix, xts time series, etc.)

Examples

newenv <- new.env()
rutils::do_call_assign(
   func=get_col,
   symbolv=rutils::etfenv$symbolv,
   outv="prices",
   inenv=etfenv, outenv=newenv)

algoquant/rutils documentation built on June 10, 2025, 3:55 p.m.