derived_catalog_do: Performs 'do' operations on the internal catalog of derived...

Description Usage Arguments Details Value References Examples

View source: R/derived_catalog_do.R

Description

The function takes a string argument representing an operation to be performed on a catalog of factors. The qualifier derived indicates that the catalog pertains to derived factors, which are built from so-called parent factors. Note that the catalog can't be modified by the user as it is defined internally to protect its integrity and that its existence is checked before implementing the selected command operator.

Usage

1
2
3
4
derived_catalog_do(
  operation = c("count", "fields", "get", "keys", "show", "src_hdl", "validate_entry"),
  arg_supp = list()
)

Arguments

operation

A string object, representing a command operator.

arg_supp

A named list with items hdl, region and frequency to support the command operator validate_entry. See details.

Details

The internal catalog is used primarily to encode and maintain the parameters required to build each derived factor, which belongs to an algebraic or econometric category. The first category includes two (and possibly more) parent factors which are combined via an algebraic formula. A typical example would be the US Treasury term spread (derived factor) expressed as the yield difference between a long-dated and a short-dated maturity (parent factors). The second category includes any number of parent factors which are transformed by an econometric or statistical procedure (e.g. moving average, fitted values from a regression model, etc).

The underlying catalog structure is a register object using the infrastructure developed in the package registry, which is endowed with:

It is important to note that the function and its underlying catalog have two additional purposes. First it provides a wrapper for a selected number of registry native functions, allowing a user unfamiliar with the registry framework to access the catalog with simple and intuitive function calls. Second, the building process is governed by the function build_derived_factor(...), which in turn has an internal gatekeeper. Prior to the building procedure, the requested factor must be confirmed as a valid catalog entry. This general framework tightly controls the building process specific to each factor and prevents the unintended manufacturing of additional derived factors.

From a broader perspective, the internal object bindr::derived_catalog is to the function bindr::build_derived_factor what factorr::catalog is to the function factorr::fetch. Each catalog in its respective package provides the underlying engine from which their associated functions inherit some functional behavior. Thus both packages (factorr, bindr) have a common structural thread.

The function behaves differently under different operators, which is a primitive form of function polymorphism. Each operator comes in the form of a verb closely matching the intended operation. The command operator get returns a copy of the catalog (a register object), so that a user familiar with the package registry can extensively search/filter the catalog along any field. For additional details on how to manipulate and query registry objects, please consult the registry package documentation, and in particular the regobj Help Page. See also the registry package vignette from \insertCiteMeyer;textualbindr

The argument arg_supp is required to support the command operator validate_entry, but is otherwise ignored. The argument must be of the from arg_supp = list(hdl = < string >, region = <string>, frequency = < string >). Deviation from this form, either in object type, cardinality or ordinality generates an error. The operator validate_entry internally verifies that the unique key formed by hdl, region and frequency maps to an existing entry.

Value

Integer

Operator count returns the number of catalog entries.

printout

Operator fields prints to console every registry field and their associated attributes.

Registry object

Operator get returns the underlying registry object supporting the catalog structure.

printout

Operator keys prints to console all unique keys formed by hdl, region and frequency.

printout

Operator show prints to console the entire catalog (i.e. all entries).

Tibble object

Operator src_hdl prints a tibble of source handles associated with valid catalog entries. Useful with bindr::assemble_factor()

entry/NULL

Operator validate_entry return a valid catalog entry (as a named list), otherwise returns NULL if the parameters in arg_supp do not map to a valid catalog entry.

References

\insertAllCited

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 

View the entire derived catalog:

   derived_catalog_do(operation = 'show')

Validate a derived catalog entry:

   derived_catalog_do(operation = 'validate_entry',
                      arg_supp = list(hdl = 'TERM',
                                      region = 'US',
                                      frequency = 'M'))


## End(Not run)

fognyc/bindr documentation built on Dec. 4, 2020, 12:33 p.m.