Learn R Programming

FinancialInstrument (version 1.4.1)

buildHierarchy: Construct a hierarchy of instruments useful for aggregation

Description

Construct a hierarchy of instruments useful for aggregation

Usage

buildHierarchy(primary_ids, ...)

Value

Constructs a data.frame that contains the list of assets in the first column and the category or factor for grouping at each level in the following columns

Arguments

primary_ids

A character vector of instrument primary_ids to be included in the hierarchy list

...

character names of instrument attributes in top-down order.

Author

Peter Carl, Alexis Petit, Garrett See

See Also

instrument.table

Examples

Run this code
if (FALSE) {
# rm_instruments(keep.currencies=FALSE)
## Define some stocks
update_instruments.TTR(c("XOM", "IBM", "CVX", "WMT", "GE"), exchange="NYSE")

buildHierarchy(ls_instruments(), "type")
buildHierarchy(ls_stocks(), c("Name", "Sector"))
buildHierarchy(ls_stocks(), "Industry", "MarketCap")
}

Run the code above in your browser using DataLab