[Returnanalytics-commits] r2299 - pkg/PerformanceAnalytics/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Nov 12 21:57:15 CET 2012
Author: braverock
Date: 2012-11-12 21:57:15 +0100 (Mon, 12 Nov 2012)
New Revision: 2299
Modified:
pkg/PerformanceAnalytics/R/Return.excess.R
Log:
- further updates to catch more use cases for Return.excess
Modified: pkg/PerformanceAnalytics/R/Return.excess.R
===================================================================
--- pkg/PerformanceAnalytics/R/Return.excess.R 2012-11-12 19:49:53 UTC (rev 2298)
+++ pkg/PerformanceAnalytics/R/Return.excess.R 2012-11-12 20:57:15 UTC (rev 2299)
@@ -68,24 +68,18 @@
columnname.Rf=colnames(Rf)
}
else {
- #indexseries=index(R)
columnname.Rf=Rf
- #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
+ Rf = reclass(rep(Rf,length(index(R))),R) #patch thanks to Josh to deal w/ TZ issue
}
## prototype
## xts(apply(managers[,1:6],2,FUN=function(R,Rf,order.by) {xts(R,order.by=order.by)-Rf}, Rf=xts(managers[,10,drop=F]),order.by=index(managers)),order.by=index(managers))
+
+ result = do.call(merge, lapply(1:NCOL(R), function(nc) R[,nc] - coredata(Rf))) # thanks Jeff!
- return.excess <- function (R,Rf)
- { # a function to be called by apply on the inner loop
- xR = coredata(as.xts(R)-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)
+ #if (!is.matrix(result)) result = matrix(result, ncol=ncol(R))
+ if(!is.null(dim(result))) colnames(result) = paste(colnames(R), ">", columnname.Rf)
+ #result = reclass(result, R)
# RESULTS:
return(result)
More information about the Returnanalytics-commits
mailing list