[Returnanalytics-commits] r3521 - in pkg/PerformanceAnalytics: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Sep 2 20:54:46 CEST 2014
Author: rossbennett34
Date: 2014-09-02 20:54:45 +0200 (Tue, 02 Sep 2014)
New Revision: 3521
Modified:
pkg/PerformanceAnalytics/R/zerofill.R
pkg/PerformanceAnalytics/man/zerofill.Rd
Log:
Modifying zerofill to avoid loops and use method="xts" in checkData. Minor edits to zerofill man file.
Modified: pkg/PerformanceAnalytics/R/zerofill.R
===================================================================
--- pkg/PerformanceAnalytics/R/zerofill.R 2014-08-30 14:40:16 UTC (rev 3520)
+++ pkg/PerformanceAnalytics/R/zerofill.R 2014-09-02 18:54:45 UTC (rev 3521)
@@ -16,23 +16,18 @@
#' zerofill
#'
-#' Fill NA's with zeros in a time series to allow analysis when the matrix must
+#' Fill NA's with zeros in a time series to allow analysis when the data must
#' be complete.
#'
#' Note that this function has risks, use carefully. Complete data is
-#' preferred. Barring that, filling a small percentage of results in a the
-#' middle of a large set are unlikely to cause problems. Barring that, realize
+#' preferred. Barring that, filling a small percentage of results in the
+#' middle of a large set is unlikely to cause problems. Barring that, realize
#' that this will skew your results.
#'
#' @param x time series to zero fill
#' @export
zerofill <- function (x) {
- mat<-checkData(x,"matrix")
- for(column in 1:ncol(mat)){
- for (row in 1:nrow(mat)){
- if(is.na(mat[row,column])) mat[row,column] <- 0
- }
- }
- x<-reclass(mat,x)
+ x <- checkData(x,"xts")
+ x[is.na(x)] <- 0
return(x)
}
Modified: pkg/PerformanceAnalytics/man/zerofill.Rd
===================================================================
--- pkg/PerformanceAnalytics/man/zerofill.Rd 2014-08-30 14:40:16 UTC (rev 3520)
+++ pkg/PerformanceAnalytics/man/zerofill.Rd 2014-09-02 18:54:45 UTC (rev 3521)
@@ -9,13 +9,12 @@
}
\description{
Fill NA's with zeros in a time series to allow analysis
-when the matrix must be complete.
+when the data must be complete.
}
\details{
Note that this function has risks, use carefully. Complete
data is preferred. Barring that, filling a small
-percentage of results in a the middle of a large set are
+percentage of results in the middle of a large set is
unlikely to cause problems. Barring that, realize that this
will skew your results.
}
-
More information about the Returnanalytics-commits
mailing list