[Blotter-commits] r496 - pkg/FinancialInstrument/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Dec 14 16:53:13 CET 2010


Author: peter_carl
Date: 2010-12-14 16:53:12 +0100 (Tue, 14 Dec 2010)
New Revision: 496

Modified:
   pkg/FinancialInstrument/R/buildHierarchy.R
Log:
- added make.names to ensure compatability with getInstrument
- fixed function spelling


Modified: pkg/FinancialInstrument/R/buildHierarchy.R
===================================================================
--- pkg/FinancialInstrument/R/buildHierarchy.R	2010-12-14 15:13:56 UTC (rev 495)
+++ pkg/FinancialInstrument/R/buildHierarchy.R	2010-12-14 15:53:12 UTC (rev 496)
@@ -1,4 +1,4 @@
-#' Construct a heirarchy of instruments useful for aggregation
+#' Construct a hierarchy of instruments useful for aggregation
 #'
 #' All 'currency' instruments must be defined before instruments of other types may be defined.
 #'
@@ -12,8 +12,9 @@
 #' @seealso
 # TODO add a link to PortfolioAnalytics attribution functions, when they exist
 #' @export
-buildHeirarchy <- function(primary_ids, levels, ...) {
+buildHierarchy <- function(primary_ids, levels, ...) {
     out = data.frame(NA)
+    primary_ids = make.names(primary_ids)
     for(primary_id in primary_ids) {
         tmp_instr = try(getInstrument(primary_id))
         # TODO finish error checking
@@ -26,7 +27,7 @@
             else
                 attrs = attr
         }
-        if(!is.na(out))
+        if(!is.na(out[1]))
             out = rbind(out, attrs)
         else
             out = attrs



More information about the Blotter-commits mailing list