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,
  output,
  env_in = .GlobalEnv,
  env_out = .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.

output

The string with name of output object.

env_in

The environment containing the input symbolv.

env_out

The environment for creating the output.

...

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

new_env <- new.env()
rutils::do_call_assign(
   func=get_col,
   symbolv=rutils::etfenv$symbolv,
   output="prices",
   env_in=etfenv, env_out=new_env)

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