[Rcpp-commits] r4200 - in pkg: . RcppXts RcppXts/R RcppXts/inst RcppXts/man RcppXts/src RcppXts/tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jan 13 04:23:13 CET 2013


Author: edd
Date: 2013-01-13 04:23:09 +0100 (Sun, 13 Jan 2013)
New Revision: 4200

Added:
   pkg/RcppXts/
   pkg/RcppXts/.Rbuildignore
   pkg/RcppXts/ChangeLog
   pkg/RcppXts/DESCRIPTION
   pkg/RcppXts/NAMESPACE
   pkg/RcppXts/R/
   pkg/RcppXts/R/zzz.R
   pkg/RcppXts/cleanup
   pkg/RcppXts/inst/
   pkg/RcppXts/inst/NEWS.Rd
   pkg/RcppXts/man/
   pkg/RcppXts/man/RcppXts-package.Rd
   pkg/RcppXts/src/
   pkg/RcppXts/src/Makevars
   pkg/RcppXts/src/Makevars.win
   pkg/RcppXts/src/xtsMod.cpp
   pkg/RcppXts/tests/
   pkg/RcppXts/tests/checks.R
Log:
committing a first and not entirely ready version of RcppXts

Added: pkg/RcppXts/.Rbuildignore
===================================================================
--- pkg/RcppXts/.Rbuildignore	                        (rev 0)
+++ pkg/RcppXts/.Rbuildignore	2013-01-13 03:23:09 UTC (rev 4200)
@@ -0,0 +1,2 @@
+^.*\.Rproj$
+^\.Rproj\.user$

Added: pkg/RcppXts/ChangeLog
===================================================================
--- pkg/RcppXts/ChangeLog	                        (rev 0)
+++ pkg/RcppXts/ChangeLog	2013-01-13 03:23:09 UTC (rev 4200)
@@ -0,0 +1,4 @@
+2013-01-12  Dirk Eddelbuettel  <edd at debian.org>
+
+	* DESCRIPTION (Version): 0.0.1
+

Added: pkg/RcppXts/DESCRIPTION
===================================================================
--- pkg/RcppXts/DESCRIPTION	                        (rev 0)
+++ pkg/RcppXts/DESCRIPTION	2013-01-13 03:23:09 UTC (rev 4200)
@@ -0,0 +1,16 @@
+Package: RcppXts
+Type: Package
+Title: Interface the xts API via Rcpp
+Version: 0.0.1
+Date: $Date$
+Author: Dirk Eddelbuettel
+Maintainer: Dirk Eddelbuettel <edd at debian.org>
+Description: This package provides access to some of the C level functions of
+ the xts package.  
+ .
+ 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
+LinkingTo: Rcpp, xts
+RcppModules: xts


Property changes on: pkg/RcppXts/DESCRIPTION
___________________________________________________________________
Added: svn:keywords
   + Date

Added: pkg/RcppXts/NAMESPACE
===================================================================
--- pkg/RcppXts/NAMESPACE	                        (rev 0)
+++ pkg/RcppXts/NAMESPACE	2013-01-13 03:23:09 UTC (rev 4200)
@@ -0,0 +1,5 @@
+useDynLib(RcppXts)
+exportPattern("^[[:alpha:]]+")
+import(Rcpp)
+import(xts)
+

Added: pkg/RcppXts/R/zzz.R
===================================================================
--- pkg/RcppXts/R/zzz.R	                        (rev 0)
+++ pkg/RcppXts/R/zzz.R	2013-01-13 03:23:09 UTC (rev 4200)
@@ -0,0 +1,4 @@
+
+loadModule("xts", TRUE)
+
+

Added: pkg/RcppXts/cleanup
===================================================================
--- pkg/RcppXts/cleanup	                        (rev 0)
+++ pkg/RcppXts/cleanup	2013-01-13 03:23:09 UTC (rev 4200)
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+rm -f src/*.o src/*.so src/symbols.rds
+
+#rm -rf vignettes/auto/ vignettes/*.log vignettes/*.aux vignettes/*.out vignettes/*.tex
+
+find . -name \*~ -exec rm {} \;


Property changes on: pkg/RcppXts/cleanup
___________________________________________________________________
Added: svn:executable
   + *

Added: pkg/RcppXts/inst/NEWS.Rd
===================================================================
--- pkg/RcppXts/inst/NEWS.Rd	                        (rev 0)
+++ pkg/RcppXts/inst/NEWS.Rd	2013-01-13 03:23:09 UTC (rev 4200)
@@ -0,0 +1,13 @@
+\name{NEWS}
+\title{News for Package \pkg{RcppCNPy}}
+\newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}}
+
+\section{Changes in version 0.0.1 (2012-07-04)}{
+  \itemize{
+    \item Initial version, as a Rcpp modules wrapping of code in
+    \cpkg{xts} itself. 
+    \item At present, no added functionality is provided but the package
+    builds and loads and established a base from which extensions can be
+    built.
+  } 
+}

Added: pkg/RcppXts/man/RcppXts-package.Rd
===================================================================
--- pkg/RcppXts/man/RcppXts-package.Rd	                        (rev 0)
+++ pkg/RcppXts/man/RcppXts-package.Rd	2013-01-13 03:23:09 UTC (rev 4200)
@@ -0,0 +1,28 @@
+\name{RcppXts-package}
+\alias{RcppXts-package}
+\alias{RcppXts}
+\alias{coredata_}
+\alias{isOrdered_}
+\alias{isXts_}
+\alias{naCheck_}
+\alias{tryXts_}
+\docType{package}
+\title{Interface to the C API of xts}
+\description{This package helps with an Rcpp-based interface to the API
+  of the \pkg{xts} package.}
+\usage{
+  coredata_(x)
+  isOrdered_(x, increasing, strictly)
+  isXts_(x)
+  naCheck_(x, check)
+  tryXts_(x)
+}
+\arguments{
+  \item{x}{an \code{xts} object}
+  \item{increasing}{a boolean switch}
+  \item{strictly}{a boolean switch}
+  \item{check}{a boolean switch}
+}
+\author{Dirk Eddelbuettel}
+\keyword{package}
+\seealso{\code{\link[xts:xts-package]{xts}}}

Added: pkg/RcppXts/src/Makevars
===================================================================
--- pkg/RcppXts/src/Makevars	                        (rev 0)
+++ pkg/RcppXts/src/Makevars	2013-01-13 03:23:09 UTC (rev 4200)
@@ -0,0 +1,27 @@
+## Use the R_HOME indirection to support installations of multiple R version
+PKG_LIBS = `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"`
+
+## As an alternative, one can also add this code in a file 'configure'
+##
+##    PKG_LIBS=`${R_HOME}/bin/Rscript -e "Rcpp:::LdFlags()"`
+## 
+##    sed -e "s|@PKG_LIBS@|${PKG_LIBS}|" \
+##        src/Makevars.in > src/Makevars
+## 
+## which together with the following file 'src/Makevars.in'
+##
+##    PKG_LIBS = @PKG_LIBS@
+##
+## can be used to create src/Makevars dynamically. This scheme is more
+## powerful and can be expanded to also check for and link with other
+## libraries.  It should be complemented by a file 'cleanup'
+##
+##    rm src/Makevars
+##
+## which removes the autogenerated file src/Makevars. 
+##
+## Of course, autoconf can also be used to write configure files. This is
+## done by a number of packages, but recommended only for more advanced users
+## comfortable with autoconf and its related tools.
+
+

Added: pkg/RcppXts/src/Makevars.win
===================================================================
--- pkg/RcppXts/src/Makevars.win	                        (rev 0)
+++ pkg/RcppXts/src/Makevars.win	2013-01-13 03:23:09 UTC (rev 4200)
@@ -0,0 +1,3 @@
+
+## Use the R_HOME indirection to support installations of multiple R version
+PKG_LIBS = $(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" -e "Rcpp:::LdFlags()")

Added: pkg/RcppXts/src/xtsMod.cpp
===================================================================
--- pkg/RcppXts/src/xtsMod.cpp	                        (rev 0)
+++ pkg/RcppXts/src/xtsMod.cpp	2013-01-13 03:23:09 UTC (rev 4200)
@@ -0,0 +1,102 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
+//
+// xtsMod.cpp: Rcpp R/C++ modules interface to xts
+//
+// Copyright (C) 2012  Dirk Eddelbuettel
+//
+// This file is part of RcppCNPy.
+//
+// RcppXts is free software: you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// RcppXts is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with RcppXts.  If not, see <http://www.gnu.org/licenses/>.
+
+#include <Rcpp.h>               // need to include the main Rcpp header file only
+
+// what is in xts.h does not matter; what matters is what has been 'registered' 
+// at the end of init.c in the xts sources
+
+extern "C" {
+    #define class xts_class
+    #include <xts.h>    	// xts header
+    #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
+
+    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);
+}
+
+bool wrapNaCheck(SEXP x, SEXP y) {      // wrapped so that we get a bool 
+    return naCheck(x, y);
+}
+
+RCPP_MODULE(xts) {
+
+    using namespace Rcpp;
+
+    function("isOrdered_",
+             &do_is_ordered,
+             List::create(Named("x"),
+                          Named("increasing") = true, 
+                          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")),
+             "Tests whether object is of xts type");
+
+    function("tryXts_",
+             &tryXts,
+             List::create(Named("x")),
+             "Calls try.xts()");
+
+#if 0
+    function("rbindXts",
+             &rbindXts,
+             List::create(Named("x")),
+             "Combine xts objects rowwise");
+#endif
+
+    function("naCheck_",
+             &wrapNaCheck,
+             List::create(Named("x"),
+                          Named("check") = true),
+             "Tests whether object contains non-leading NA values"); 
+
+}

Added: pkg/RcppXts/tests/checks.R
===================================================================
--- pkg/RcppXts/tests/checks.R	                        (rev 0)
+++ pkg/RcppXts/tests/checks.R	2013-01-13 03:23:09 UTC (rev 4200)
@@ -0,0 +1,11 @@
+
+library(RcppXts)
+
+X <- xts(1:4, order.by=Sys.time()+0:3)
+
+isOrdered_(X)
+coredata_(X)
+isXts_(X)
+tryXts_(as.zoo(X))
+#rbindXts(X)
+naCheck_(X)



More information about the Rcpp-commits mailing list