[Returnanalytics-commits] r2888 - pkg/PortfolioAnalytics/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Aug 26 02:47:56 CEST 2013


Author: rossbennett34
Date: 2013-08-26 02:47:55 +0200 (Mon, 26 Aug 2013)
New Revision: 2888

Modified:
   pkg/PortfolioAnalytics/R/constrained_objective.R
Log:
Making 'StdDev' the name of the objective measure if the objective is 'var' in constrained_objective so it does not have to be changed in the generics or extract stats methods.

Modified: pkg/PortfolioAnalytics/R/constrained_objective.R
===================================================================
--- pkg/PortfolioAnalytics/R/constrained_objective.R	2013-08-25 23:28:50 UTC (rev 2887)
+++ pkg/PortfolioAnalytics/R/constrained_objective.R	2013-08-26 00:47:55 UTC (rev 2888)
@@ -587,8 +587,13 @@
         tmp_measure <- try((do.call(fun,.formals)), silent=TRUE)
         
         if(isTRUE(trace) | isTRUE(storage)) {
-          if(is.null(names(tmp_measure))) names(tmp_measure) <- objective$name
-          tmp_return[[objective$name]] <- tmp_measure
+          # Subsitute 'StdDev' if the objective name is 'var'
+          # if the user passes in var as an objective name, we are actually
+          # calculating StdDev, so we need to change the name here.
+          tmp_objname <- objective$name
+          if(tmp_objname == "var") tmp_objname <- "StdDev"
+          if(is.null(names(tmp_measure))) names(tmp_measure) <- tmp_objname
+          tmp_return[[tmp_objname]] <- tmp_measure
         }
         
         if(inherits(tmp_measure, "try-error")) { 



More information about the Returnanalytics-commits mailing list