[Xts-commits] r782 - pkg/xts/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Jul 6 16:42:39 CEST 2013
Author: bodanker
Date: 2013-07-06 16:42:38 +0200 (Sat, 06 Jul 2013)
New Revision: 782
Modified:
pkg/xts/R/period.R
Log:
- add checks to period.sum/prod/min/max to ensure INDEX in [0,nrow(x)]
Modified: pkg/xts/R/period.R
===================================================================
--- pkg/xts/R/period.R 2013-06-27 02:27:03 UTC (rev 781)
+++ pkg/xts/R/period.R 2013-07-06 14:42:38 UTC (rev 782)
@@ -38,7 +38,7 @@
`period.sum` <-
function(x,INDEX) {
if(NCOL(x) > 1) stop("single column data only")
-
+ if(min(INDEX) < 0 || max(INDEX) > NROW(x)) stop("INDEX must be >= 0 and <= nrow(x)")
ep <- INDEX
if(ep[1] != 0) ep <- c(0,ep)
if(ep[length(ep)] != NROW(x)) ep <- c(ep,NROW(x))
@@ -58,6 +58,7 @@
`period.prod` <-
function(x,INDEX) {
if(NCOL(x) > 1) stop("single column data only")
+ if(min(INDEX) < 0 || max(INDEX) > NROW(x)) stop("INDEX must be >= 0 and <= nrow(x)")
ep <- INDEX
if(ep[1] != 0) ep <- c(0,ep)
if(ep[length(ep)] != NROW(x)) ep <- c(ep,NROW(x))
@@ -77,6 +78,7 @@
`period.max` <-
function(x,INDEX) {
if(NCOL(x) > 1) stop("single column data only")
+ if(min(INDEX) < 0 || max(INDEX) > NROW(x)) stop("INDEX must be >= 0 and <= nrow(x)")
ep <- INDEX
if(ep[1] != 0) ep <- c(0,ep)
if(ep[length(ep)] != NROW(x)) ep <- c(ep,NROW(x))
@@ -96,6 +98,7 @@
`period.min` <-
function(x,INDEX) {
if(NCOL(x) > 1) stop("single column data only")
+ if(min(INDEX) < 0 || max(INDEX) > NROW(x)) stop("INDEX must be >= 0 and <= nrow(x)")
ep <- INDEX
if(ep[1] != 0) ep <- c(0,ep)
if(ep[length(ep)] != NROW(x)) ep <- c(ep,NROW(x))
More information about the Xts-commits
mailing list