[Xts-commits] r646 - in pkg/xtsExtra: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 20 02:05:38 CEST 2012


Author: weylandt
Date: 2012-06-20 02:05:38 +0200 (Wed, 20 Jun 2012)
New Revision: 646

Modified:
   pkg/xtsExtra/NAMESPACE
   pkg/xtsExtra/R/groupGenerics.R
   pkg/xtsExtra/R/subset.print.xtsdf.R
   pkg/xtsExtra/man/xtsdf.Rd
Log:
Added xtsdf subassignment: still slow since coerces to df internally

Modified: pkg/xtsExtra/NAMESPACE
===================================================================
--- pkg/xtsExtra/NAMESPACE	2012-06-19 23:09:56 UTC (rev 645)
+++ pkg/xtsExtra/NAMESPACE	2012-06-20 00:05:38 UTC (rev 646)
@@ -60,6 +60,7 @@
 S3method(as.xts, xtsdf)
 
 S3method(`[`,xtsdf)
+S3method(`[<-`, xtsdf)
 S3method(print, xtsdf)
 S3method(str, xtsdf)
 

Modified: pkg/xtsExtra/R/groupGenerics.R
===================================================================
--- pkg/xtsExtra/R/groupGenerics.R	2012-06-19 23:09:56 UTC (rev 645)
+++ pkg/xtsExtra/R/groupGenerics.R	2012-06-20 00:05:38 UTC (rev 646)
@@ -19,11 +19,13 @@
 #   should we use inner joins/merges first? Date alignment like xts? Both? Neither?
 
 Ops.xtsdf <- function(e1, e2 = NULL){
+  # Would be much happier to do this without ever using as.df for speed
   as.xtsdf(match.fun(.Generic)(as.data.frame(e1), e2), order.by = index(e1))
 }
 
 # This one seems solid
 Math.xtsdf <- function(x, ...){
+  # Would be much happier to do this without ever using as.df for speed
   .Class <- "data.frame"
   as.xtsdf(NextMethod(.Generic), order.by = index(x))
 }

Modified: pkg/xtsExtra/R/subset.print.xtsdf.R
===================================================================
--- pkg/xtsExtra/R/subset.print.xtsdf.R	2012-06-19 23:09:56 UTC (rev 645)
+++ pkg/xtsExtra/R/subset.print.xtsdf.R	2012-06-20 00:05:38 UTC (rev 646)
@@ -32,7 +32,15 @@
   
 }
 
+`[<-.xtsdf` <- function(x, i, j, value){
+  # Would be much happier to do this without ever using as.df for speed
+  x.df <- as.data.frame(x, stringsAsFactors = FALSE)
+  x.df[i,j] <- value
+  as.xtsdf(x.df, order.by = index(x))
+}
+
 print.xtsdf <- function(x, ...){
+  # Would be much happier to do this without ever using as.df for speed
   print(as.data.frame(x, row.names = index(x)), ...)
 }
 

Modified: pkg/xtsExtra/man/xtsdf.Rd
===================================================================
--- pkg/xtsExtra/man/xtsdf.Rd	2012-06-19 23:09:56 UTC (rev 645)
+++ pkg/xtsExtra/man/xtsdf.Rd	2012-06-20 00:05:38 UTC (rev 646)
@@ -21,10 +21,10 @@
   \item{order.by}{ a corresponding vector of unique times/dates - must be
 of a known time-based class. See details of \code{xts}.}
   \item{frequency}{ numeric indicating frequency of \code{order.by}. See details of \code{xts}. }
-  \item{unique}{ should index be checked for unique time-stamps? }
+  \item{unique}{Logical. Should index be checked for unique time-stamps? }
   \item{tzone}{ time zone of series }
-  \item{stringsAsFactors}{ Should strings be converted to factors?}
-  \item{check.names}{Should column names be made syntactically correct?}
+  \item{stringsAsFactors}{Logical. Should strings be converted to factors? Note that \code{xts} does not currently support factors so this doesn't really do much..}
+  \item{check.names}{Logical. Should column names be made syntactically correct?}
   \item{x}{An object to be tested or coerced to class \code{xtsdf}.}
 }
 \details{



More information about the Xts-commits mailing list