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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Sep 18 07:08:47 CEST 2013


Author: rossbennett34
Date: 2013-09-18 07:08:46 +0200 (Wed, 18 Sep 2013)
New Revision: 3129

Modified:
   pkg/PortfolioAnalytics/R/charts.DE.R
   pkg/PortfolioAnalytics/R/charts.GenSA.R
   pkg/PortfolioAnalytics/R/charts.PSO.R
   pkg/PortfolioAnalytics/R/charts.ROI.R
   pkg/PortfolioAnalytics/R/charts.RP.R
Log:
Adding check for returns object of chart.Scatter.* functions.

Modified: pkg/PortfolioAnalytics/R/charts.DE.R
===================================================================
--- pkg/PortfolioAnalytics/R/charts.DE.R	2013-09-17 20:15:09 UTC (rev 3128)
+++ pkg/PortfolioAnalytics/R/charts.DE.R	2013-09-18 05:08:46 UTC (rev 3129)
@@ -100,6 +100,7 @@
   if(!inherits(object, "optimize.portfolio.DEoptim")) stop("object must be of class 'optimize.portfolio.DEoptim'")
   
   R <- object$R
+  if(is.null(R)) stop("Returns object not detected, must run optimize.portfolio with trace=TRUE")
   portfolio <- object$portfolio
   xtract = extractStats(object)
   columnnames = colnames(xtract)

Modified: pkg/PortfolioAnalytics/R/charts.GenSA.R
===================================================================
--- pkg/PortfolioAnalytics/R/charts.GenSA.R	2013-09-17 20:15:09 UTC (rev 3128)
+++ pkg/PortfolioAnalytics/R/charts.GenSA.R	2013-09-18 05:08:46 UTC (rev 3129)
@@ -83,6 +83,7 @@
   if(!inherits(object, "optimize.portfolio.GenSA")) stop("object must be of class 'optimize.portfolio.GenSA'")
   
   R <- object$R
+  if(is.null(R)) stop("Returns object not detected, must run optimize.portfolio with trace=TRUE")
   # If the user does not pass in rp, then we will generate random portfolios
   if(rp){
     permutations <- match.call(expand.dots=TRUE)$permutations

Modified: pkg/PortfolioAnalytics/R/charts.PSO.R
===================================================================
--- pkg/PortfolioAnalytics/R/charts.PSO.R	2013-09-17 20:15:09 UTC (rev 3128)
+++ pkg/PortfolioAnalytics/R/charts.PSO.R	2013-09-18 05:08:46 UTC (rev 3129)
@@ -82,6 +82,7 @@
   if(!inherits(object, "optimize.portfolio.pso")) stop("object must be of class 'optimize.portfolio.pso'")
   
   R <- object$R
+  if(is.null(R)) stop("Returns object not detected, must run optimize.portfolio with trace=TRUE")
   # portfolio <- object$portfolio
   xtract = extractStats(object)
   columnnames = colnames(xtract)

Modified: pkg/PortfolioAnalytics/R/charts.ROI.R
===================================================================
--- pkg/PortfolioAnalytics/R/charts.ROI.R	2013-09-17 20:15:09 UTC (rev 3128)
+++ pkg/PortfolioAnalytics/R/charts.ROI.R	2013-09-18 05:08:46 UTC (rev 3129)
@@ -84,6 +84,7 @@
   if(!inherits(object, "optimize.portfolio.ROI")) stop("object must be of class 'optimize.portfolio.ROI'")
   
   R <- object$R
+  if(is.null(R)) stop("Returns object not detected, must run optimize.portfolio with trace=TRUE")
   # If the user does not pass in rp, then we will generate random portfolios
   if(rp){
     permutations <- match.call(expand.dots=TRUE)$permutations

Modified: pkg/PortfolioAnalytics/R/charts.RP.R
===================================================================
--- pkg/PortfolioAnalytics/R/charts.RP.R	2013-09-17 20:15:09 UTC (rev 3128)
+++ pkg/PortfolioAnalytics/R/charts.RP.R	2013-09-18 05:08:46 UTC (rev 3129)
@@ -100,7 +100,8 @@
   if(!inherits(object, "optimize.portfolio.random")){
     stop("object must be of class 'optimize.portfolio.random'")
   }
-  R <- object$R  
+  R <- object$R
+  if(is.null(R)) stop("Returns object not detected, must run optimize.portfolio with trace=TRUE")
   xtract = extractStats(object)
   columnnames = colnames(xtract)
   #return.column = grep(paste("objective_measures",return.col,sep='.'),columnnames)



More information about the Returnanalytics-commits mailing list