[Xts-commits] r614 - pkg/xts/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Apr 22 05:24:32 CEST 2012


Author: bodanker
Date: 2012-04-22 05:24:31 +0200 (Sun, 22 Apr 2012)
New Revision: 614

Modified:
   pkg/xts/R/indexClass.R
Log:
- Make indexClass<-.xts throw error if value='POSIXt'


Modified: pkg/xts/R/indexClass.R
===================================================================
--- pkg/xts/R/indexClass.R	2012-04-02 16:39:35 UTC (rev 613)
+++ pkg/xts/R/indexClass.R	2012-04-22 03:24:31 UTC (rev 614)
@@ -44,8 +44,12 @@
   if(!is.character(value) && length(value) != 1)
     stop('improperly specified value for indexClass')
 
-  # should users really be allowed to set value to 'POSIXt'?
-  if(!value[1] %in% c('dates','chron','POSIXt','POSIXlt','POSIXct','Date','timeDate','yearmon','yearqtr','xtime') )
+  # remove 'POSIXt' from value, to prevent indexClass(x) <- 'POSIXt'
+  value <- value[!value %in% "POSIXt"]
+  if(length(value)==0L)
+    stop(paste('unsupported',sQuote('indexClass'),'indexing type: POSIXt'))
+
+  if(!value[1] %in% c('dates','chron','POSIXlt','POSIXct','Date','timeDate','yearmon','yearqtr','xtime') )
        stop(paste('unsupported',sQuote('indexClass'),'indexing type:',as.character(value[[1]])))
 
   # Add 'POSIXt' virtual class



More information about the Xts-commits mailing list