[Returnanalytics-commits] r2092 - pkg/PerformanceAnalytics/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Jun 29 14:09:33 CEST 2012
Author: matthieu_lestel
Date: 2012-06-29 14:09:33 +0200 (Fri, 29 Jun 2012)
New Revision: 2092
Modified:
pkg/PerformanceAnalytics/R/DownsideDeviation.R
Log:
modification of DownsideDeviation to make it easier to use for other functions
Modified: pkg/PerformanceAnalytics/R/DownsideDeviation.R
===================================================================
--- pkg/PerformanceAnalytics/R/DownsideDeviation.R 2012-06-29 11:25:08 UTC (rev 2091)
+++ pkg/PerformanceAnalytics/R/DownsideDeviation.R 2012-06-29 12:09:33 UTC (rev 2092)
@@ -120,7 +120,7 @@
method = method[1]
- if (is.vector(R)) {
+ if (ncol(R)==1 || is.vector(R) || is.null(R)) {
R = na.omit(R)
r = subset(R, R < MAR)
@@ -153,9 +153,9 @@
result<-t(result)
colnames(result) = colnames(R)
if(potential)
- rownames(result) = paste("Downside Potential (MAR = ", round(mean(MAR)*100,1),"%)", sep="")
+ rownames(result) = paste("Downside Potential (MAR = ", round(mean(MAR),1),"%)", sep="")
else
- rownames(result) = paste("Downside Deviation (MAR = ", round(mean(MAR)*100,1),"%)", sep="")
+ rownames(result) = paste("Downside Deviation (MAR = ", round(mean(MAR),1),"%)", sep="")
return(result)
}
}
@@ -173,17 +173,15 @@
# FUNCTION:
- if (is.vector(R)) {
- R = na.omit(R)
+ if (is.vector(R) || is.null(R) || ncol(R)==1) {
return(DownsideDeviation(R, MAR=MAR, method="full", potential=TRUE))
}
else {
R = checkData(R, method = "matrix")
- MAR=mean(R) #dummy for R CMD check
- result = apply(R, 2, DownsidePotential)
+ result = apply(R, MARGIN = 2, DownsidePotential, MAR = MAR)
result = matrix(result, nrow=1)
colnames(result) = colnames(R)
- rownames(result) = paste("Downside Potential (MAR = ", round(mean(MAR)*100,1),"%)", sep="")
+ rownames(result) = paste("Downside Potential (MAR = ", round(mean(MAR),1),"%)", sep="")
return(result)
}
}
More information about the Returnanalytics-commits
mailing list