[Returnanalytics-commits] r2296 - pkg/PerformanceAnalytics/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Nov 12 17:58:52 CET 2012


Author: braverock
Date: 2012-11-12 17:58:52 +0100 (Mon, 12 Nov 2012)
New Revision: 2296

Modified:
   pkg/PerformanceAnalytics/R/Return.excess.R
Log:
- patch to avoid TZ issue, thanks to attention by Josh and Jeff

Modified: pkg/PerformanceAnalytics/R/Return.excess.R
===================================================================
--- pkg/PerformanceAnalytics/R/Return.excess.R	2012-11-10 14:05:28 UTC (rev 2295)
+++ pkg/PerformanceAnalytics/R/Return.excess.R	2012-11-12 16:58:52 UTC (rev 2296)
@@ -68,9 +68,10 @@
         columnname.Rf=colnames(Rf)
     }
     else {
-        indexseries=index(R)
+        #indexseries=index(R)
         columnname.Rf=Rf
-        Rf=xts(rep(Rf, length(indexseries)),order.by=indexseries)
+        #Rf=xts(rep(Rf, length(indexseries)),order.by=indexseries)
+        Rf = reclass(rep(Rf,nrow(R)),R) #patch thanks to Josh to deal w/ TZ issue
     }
 
     ## prototype
@@ -78,10 +79,10 @@
     
     return.excess <- function (R,Rf)
     { # a function to be called by apply on the inner loop
-        xR = coredata(as.xts(R)-as.xts(Rf))
+        xR = coredata(as.xts(R)-Rf)
     }
     
-    result = apply(R, MARGIN=2, FUN=return.excess, Rf=Rf)
+    result = do.call(merge, lapply(1:NCOL(R), function(nc) R[,nc] - Rf)) # thanks Jeff!
     if (!is.matrix(result)) result = matrix(result, ncol=ncol(R))
     colnames(result) = paste(colnames(R), ">", columnname.Rf)
     result = reclass(result, R)



More information about the Returnanalytics-commits mailing list