[Rcpp-commits] r4216 - in pkg/RcppXts: . src tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jan 16 04:24:08 CET 2013


Author: edd
Date: 2013-01-16 04:24:08 +0100 (Wed, 16 Jan 2013)
New Revision: 4216

Modified:
   pkg/RcppXts/ChangeLog
   pkg/RcppXts/DESCRIPTION
   pkg/RcppXts/src/xtsMod.cpp
   pkg/RcppXts/tests/checks.R
Log:
 o updated, using the new xts from svn
 o added coredata, merge, lag


Modified: pkg/RcppXts/ChangeLog
===================================================================
--- pkg/RcppXts/ChangeLog	2013-01-15 22:05:49 UTC (rev 4215)
+++ pkg/RcppXts/ChangeLog	2013-01-16 03:24:08 UTC (rev 4216)
@@ -1,3 +1,16 @@
+2013-01-15  Dirk Eddelbuettel  <edd at debian.org>
+
+	* DESCRIPTION (Version): 0.0.2
+
+	* DESCRIPTION (Depends): Versioned Depends: on xts to ensure we a
+	version greater than 0.9-1 (currently on CRAN) with corrected init.c
+
+	* src/xtsMod.cpp:
+	  o Import stubs have been moved into xts where they belong
+	  o New functions for coredata, merge, lag now that xts exports'em
+
+	* tests/check.R: Added minimal tests for new functionality
+
 2013-01-12  Dirk Eddelbuettel  <edd at debian.org>
 
 	* DESCRIPTION (Version): 0.0.1

Modified: pkg/RcppXts/DESCRIPTION
===================================================================
--- pkg/RcppXts/DESCRIPTION	2013-01-15 22:05:49 UTC (rev 4215)
+++ pkg/RcppXts/DESCRIPTION	2013-01-16 03:24:08 UTC (rev 4216)
@@ -1,7 +1,7 @@
 Package: RcppXts
 Type: Package
 Title: Interface the xts API via Rcpp
-Version: 0.0.1
+Version: 0.0.2
 Date: $Date$
 Author: Dirk Eddelbuettel
 Maintainer: Dirk Eddelbuettel <edd at debian.org>
@@ -11,6 +11,6 @@
  In its current state, the package is mostly a proof-of-concept to support
  adding useful functions, and does not yet add any of its own.
 License: GPL (>= 2)
-Depends: methods, Rcpp (>= 0.10.2), xts
+Depends: methods, Rcpp (>= 0.10.2), xts (>= 0.9-1.1)
 LinkingTo: Rcpp, xts
 RcppModules: xts

Modified: pkg/RcppXts/src/xtsMod.cpp
===================================================================
--- pkg/RcppXts/src/xtsMod.cpp	2013-01-15 22:05:49 UTC (rev 4215)
+++ pkg/RcppXts/src/xtsMod.cpp	2013-01-16 03:24:08 UTC (rev 4216)
@@ -4,7 +4,7 @@
 //
 // Copyright (C) 2012  Dirk Eddelbuettel
 //
-// This file is part of RcppCNPy.
+// This file is part of RcppXts.
 //
 // RcppXts is free software: you can redistribute it and/or modify it
 // under the terms of the GNU General Public License as published by
@@ -30,36 +30,17 @@
     #include <xts_stubs.c>      // stubs + automatic registration -- no linking
     #undef class
 
-    // We need R_GetCCallable() for the three (of six total in init.c) that did
-    // not already have such a R_GetCCallable() in xts_stubs.c
+    // We need R_GetCCallable() for the three (of six total in init.c)
+    // that did not already have such a R_GetCCallable() in
+    // xts_stubs.c -- currently xts_stub.c has: isXts, do_is_ordered, naCheck
 
-    SEXP coredata(SEXP x) {
-        static SEXP(*fun)(SEXP) = NULL;
-        if (fun == NULL) fun = (SEXP(*)(SEXP)) R_GetCCallable("xts","coredata");
-        return fun(x, y);
-    }
 
-    SEXP tryXts(SEXP x) {
-        static SEXP(*fun)(SEXP) = NULL;
-        if (fun == NULL) fun = (SEXP(*)(SEXP)) R_GetCCallable("xts","tryXts");
-        return fun(x);
-    }
-
-    SEXP rbindXts(SEXP x) {
-        static SEXP(*fun)(SEXP) = NULL;
-        if (fun == NULL) fun = (SEXP(*)(SEXP)) R_GetCCallable("xts","rbindXts");
-        return fun(x);
-    }
 }
 
-bool wrapIsXts(SEXP x) {        	// wrapped so that we get a bool
-    return isXts(x);
-}
+// wrapped so that we get a bool instead of int
+bool wrapIsXts(SEXP x)           { return isXts(x);      }
+bool wrapNaCheck(SEXP x, SEXP y) { return naCheck(x, y); }
 
-bool wrapNaCheck(SEXP x, SEXP y) {      // wrapped so that we get a bool 
-    return naCheck(x, y);
-}
-
 RCPP_MODULE(xts) {
 
     using namespace Rcpp;
@@ -71,11 +52,6 @@
                           Named("strictly") = true),
              "Tests whether object is (strictly) (increasing) ordered");
 
-    function("coredata_",
-             &coredata,         // see xts's src/init.c, and above
-             List::create(Named("x")),
-             "Extract the coredata from xts object");
-
     function("isXts_",
              &wrapIsXts,   // could also wrap xts function here via &isXts
              List::create(Named("x")),
@@ -86,12 +62,10 @@
              List::create(Named("x")),
              "Calls try.xts()");
 
-#if 0
-    function("rbindXts",
-             &rbindXts,
-             List::create(Named("x")),
-             "Combine xts objects rowwise");
-#endif
+    function("rbindXts_",
+             &do_rbind_xts,
+             List::create(Named("x"), Named("y"), Named("dup")),
+             "Combine two xts objects row-wise");
 
     function("naCheck_",
              &wrapNaCheck,
@@ -99,4 +73,14 @@
                           Named("check") = true),
              "Tests whether object contains non-leading NA values"); 
 
+    function("coredata_",
+             &coredata_xts,         // see xts's src/init.c, and above
+             List::create(Named("x")),
+             "Extract the coredata from xts object");
+
+    function("lagXts_",
+             &lagXts,
+             List::create(Named("x"), Named("k"), Named("pad")),
+             "Extract the coredata from xts object");
+
 }

Modified: pkg/RcppXts/tests/checks.R
===================================================================
--- pkg/RcppXts/tests/checks.R	2013-01-15 22:05:49 UTC (rev 4215)
+++ pkg/RcppXts/tests/checks.R	2013-01-16 03:24:08 UTC (rev 4216)
@@ -1,11 +1,15 @@
 
 library(RcppXts)
 
-X <- xts(1:4, order.by=Sys.time()+0:3)
+X  <- xts(1:4, order.by=Sys.time()+0:3)
+X2 <- xts(1:4, order.by=Sys.time()+4:7)
 
-isOrdered_(X)
-coredata_(X)
-isXts_(X)
-tryXts_(as.zoo(X))
-#rbindXts(X)
+
+stopifnot( isOrdered_(X) )
+stopifnot( coredata_(X) == coredata(X) )
+stopifnot( isXts_(X) )
+stopifnot( tryXts_(as.zoo(X)) )
+rbindXts_(X, X2, FALSE)
+rbindXts_(X, X, TRUE)
 naCheck_(X)
+lagXts_(X, 2L, TRUE)



More information about the Rcpp-commits mailing list