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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jan 28 23:40:14 CET 2013


Author: peter_carl
Date: 2013-01-28 23:40:13 +0100 (Mon, 28 Jan 2013)
New Revision: 2317

Modified:
   pkg/PerformanceAnalytics/R/chart.RollingCorrelation.R
Log:
- replaced na.pad with fill=NA


Modified: pkg/PerformanceAnalytics/R/chart.RollingCorrelation.R
===================================================================
--- pkg/PerformanceAnalytics/R/chart.RollingCorrelation.R	2013-01-28 21:38:59 UTC (rev 2316)
+++ pkg/PerformanceAnalytics/R/chart.RollingCorrelation.R	2013-01-28 22:40:13 UTC (rev 2317)
@@ -12,10 +12,9 @@
 #' bottomright, bottom, bottomleft, left, topleft, top, topright, right, or
 #' center.
 #' @param colorset color palette to use, set by default to rational choices
-#' @param na.pad TRUE/FALSE If TRUE it adds any times that would not otherwise
-#' have been in the result with a value of NA. If FALSE those times are
-#' dropped.
 #' @param \dots any other passthru parameters
+#' @details The previous parameter \code{na.pad} has been replaced with \code{fill}; use \code{fill = NA} instead of 
+#' \code{na.pad = TRUE}, or \code{fill = NULL} instead of \code{na.pad = FALSE}.
 #' @author Peter Carl
 #' @keywords ts multivariate distribution models hplot
 #' @examples
@@ -29,7 +28,7 @@
 #' 
 #' @export 
 chart.RollingCorrelation <-
-function (Ra, Rb, width = 12, xaxis = TRUE, legend.loc = NULL, colorset = (1:12), ...)
+function (Ra, Rb, width = 12, xaxis = TRUE, legend.loc = NULL, colorset = (1:12), ..., fill=NA)
 { # @author Peter Carl
 
     # DESCRIPTION:
@@ -51,7 +50,7 @@
     for(column.a in 1:columns.a) { # for each asset passed in as R
         for(column.b in 1:columns.b) { # against each asset passed in as Rb
             merged.assets = merge(Ra[,column.a,drop=FALSE], Rb[,column.b,drop=FALSE])
-            column.calc = rollapply(na.omit(merged.assets[,,drop=FALSE]), width = width, FUN= function(x) cor(x[,1,drop=FALSE], x[,2,drop=FALSE]), by = 1, by.column = FALSE, fill = if(na.pad) NA, align = "right")
+            column.calc = rollapply(na.omit(merged.assets[,,drop=FALSE]), width = width, FUN= function(x) cor(x[,1,drop=FALSE], x[,2,drop=FALSE]), by = 1, by.column = FALSE, fill = fill, align = "right")
 
             # some backflips to name the single column zoo object
             column.calc.tmp = xts(column.calc)



More information about the Returnanalytics-commits mailing list