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

Description Usage Arguments Details Value Examples

View source: R/rutils.R

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

1
2
3
4
5
6
7
8
do_call_assign(
  func_tion,
  sym_bols = NULL,
  out_put,
  env_in = .GlobalEnv,
  env_out = .GlobalEnv,
  ...
)

Arguments

func_tion

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

sym_bols

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

out_put

The string with name of output object.

env_in

The environment containing the input sym_bols.

env_out

The environment for creating the out_put.

...

Additional arguments to function func_tion().

Details

The function do_call_assign() performs an lapply loop over sym_bols, applies the function func_tion(), 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

1
2
3
4
5
6
new_env <- new.env()
rutils::do_call_assign(
   func_tion=get_col,
   sym_bols=rutils::etf_env$sym_bols,
   out_put="price_s",
   env_in=etf_env, env_out=new_env)

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