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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jan 23 18:14:25 CET 2013


Author: braverock
Date: 2013-01-23 18:14:25 +0100 (Wed, 23 Jan 2013)
New Revision: 2311

Modified:
   pkg/PerformanceAnalytics/R/Return.excess.R
Log:
- correct for Rf of length different from R

Modified: pkg/PerformanceAnalytics/R/Return.excess.R
===================================================================
--- pkg/PerformanceAnalytics/R/Return.excess.R	2013-01-23 16:21:33 UTC (rev 2310)
+++ pkg/PerformanceAnalytics/R/Return.excess.R	2013-01-23 17:14:25 UTC (rev 2311)
@@ -64,11 +64,13 @@
     # and convert it to an xts object.
     if(!is.null(dim(Rf))){
         Rf = checkData(Rf)
-        indexseries=index(cbind(R,Rf))
-        columnname.Rf=colnames(Rf)
+        coln.Rf=colnames(Rf)
+        Rft=cbind(R,Rf)
+        Rft=na.locf(Rft[,make.names(coln.Rf)])
+        Rf=Rft[which(index(Rft)==index(R)),]
     }
     else {
-        columnname.Rf=Rf
+        coln.Rf='Rf'
         Rf = reclass(rep(Rf,length(index(R))),R) #patch thanks to Josh to deal w/ TZ issue
     }
 
@@ -78,7 +80,7 @@
     result = do.call(merge, lapply(1:NCOL(R), function(nc) R[,nc] - coredata(Rf))) # thanks Jeff!
     
     #if (!is.matrix(result)) result = matrix(result, ncol=ncol(R))
-    if(!is.null(dim(result))) colnames(result) = paste(colnames(R), ">", columnname.Rf)
+    if(!is.null(dim(result))) colnames(result) = paste(colnames(R), ">", coln.Rf)
     #result = reclass(result, R)
 
     # RESULTS:



More information about the Returnanalytics-commits mailing list