[Rcpp-commits] r840 - in pkg/RcppExamples: man src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Mar 6 03:07:22 CET 2010


Author: edd
Date: 2010-03-06 03:07:21 +0100 (Sat, 06 Mar 2010)
New Revision: 840

Added:
   pkg/RcppExamples/man/RcppExamples-package.Rd
Modified:
   pkg/RcppExamples/man/RcppDate.Rd
   pkg/RcppExamples/man/RcppExample.Rd
   pkg/RcppExamples/man/RcppResultSet.Rd
   pkg/RcppExamples/man/RcppVector.Rd
   pkg/RcppExamples/src/RcppStringVectorExample.cpp
Log:
a number of fixes to the manual pages
continued work on RcppStringVectorExample ... but not quite here yet


Modified: pkg/RcppExamples/man/RcppDate.Rd
===================================================================
--- pkg/RcppExamples/man/RcppDate.Rd	2010-03-05 18:14:12 UTC (rev 839)
+++ pkg/RcppExamples/man/RcppDate.Rd	2010-03-06 02:07:21 UTC (rev 840)
@@ -4,24 +4,29 @@
 \alias{RcppDateVector}
 \alias{RcppDatetimeVector}
 \alias{RcppDateExample}
-\title{C++ classes for receiving date and datetime R objects in C++}
+\title{C++ classes for interfacing date and datetime R objects}
 \description{
   \code{RcppDate}, \code{RcppDatetime}, \code{RcppDateVector} and
-  \code{RcppDatetimeVector} are C++ classes defined in \code{Rcpp.h} that can
-  pass scalars and vectors of of \R objects of types \code{Date} and
-  \code{POSIXct}, respectively, to C++ via the \code{.Call()} function interface. 
+  \code{RcppDatetimeVector} are C++ classes defined in their respective
+  headers files.  They are part of the 'classic' Rcpp API. These classes
+  pass scalars and vectors of \R objects of types \code{Date} and
+  \code{POSIXct}, respectively, to C++ via the \code{.Call()} function
+  interface.  
   
   Member functions are provided to query the dimension of the vector or
   matrix object, convert it in a corresponding \code{C} representation.
 
   \R objects of type \code{Date}, and hence the \code{RcppDate} and
-  \code{RcppDateVector} objects, are internally represented as an integer
-  counting days since the epoch, i.e. January 1, 1970. Similarly, \R objects of type
-  \code{POSIXct} and the \code{RcppDatetime} and
-  \code{RcppDatetimeVector} objects, are internally represented as
-  seconds since the epoch.  However, \R extends the POSIX standard by
-  using a double leading to microsecond precision in timestamps. This is
-  fully supported by \code{Rcpp} as well.
+  \code{RcppDateVector} objects, are internally represented as an
+  integer counting days since the epoch, i.e. January 1,
+  1970. Similarly, \R objects of type \code{POSIXct} and the
+  \code{RcppDatetime} and \code{RcppDatetimeVector} objects, are
+  internally represented as seconds since the epoch.  However, \R
+  extends the POSIX standard by using a double leading to microsecond
+  precision in timestamps. This is fully supported by \code{Rcpp} as
+  well.
+
+  The new API currently has no explicit Date or Datetime types.
 }
 %\usage{
 %}
@@ -94,3 +99,4 @@
 }
 \keyword{programming}
 \keyword{interface}
+

Modified: pkg/RcppExamples/man/RcppExample.Rd
===================================================================
--- pkg/RcppExamples/man/RcppExample.Rd	2010-03-05 18:14:12 UTC (rev 839)
+++ pkg/RcppExamples/man/RcppExample.Rd	2010-03-06 02:07:21 UTC (rev 840)
@@ -3,12 +3,12 @@
 \alias{print.RcppExample}
 \title{Rcpp R / C++ interface example}
 \description{
-  \code{RcppExample} illustrates how the \code{Rcpp} R/C++
-  interface class library is used.
+  \code{RcppExample} illustrates how the older \code{Rcpp} R/C++ 
+  interface class library is used. It provides fairly complete coverage
+  for the older \sQuote{classic} API. 
 }
 \usage{
-RcppExample(params, nlist, numvec, nummat, df, datevec, stringvec,
-fnvec, fnlist)
+RcppExample(params, nlist, numvec, nummat, df, datevec, stringvec, fnvec, fnlist)
 \method{print}{RcppExample}(x,...)
 }
 \arguments{
@@ -26,7 +26,6 @@
   \item{...}{Extra named parameters.}
   }
 \details{
-
   The C++ represention of data frames are not passed back to R in a form
   that R recognizes as a data frame, but it is a simple matter to do the
   conversion. For example, the return value named \code{PreDF} (see

Added: pkg/RcppExamples/man/RcppExamples-package.Rd
===================================================================
--- pkg/RcppExamples/man/RcppExamples-package.Rd	                        (rev 0)
+++ pkg/RcppExamples/man/RcppExamples-package.Rd	2010-03-06 02:07:21 UTC (rev 840)
@@ -0,0 +1,37 @@
+\name{RcppExamples-package}
+\alias{RcppExamples-package}
+\alias{RcppExamples}
+\docType{package}
+\title{
+  Examples for the Rcpp R/C++ Interface library
+}
+\description{
+  This package shows some simple examples for the use of \pkg{Rcpp}.
+  Both the older ('classic') and new API are documented.    
+
+  It can also serve as a working template to create packages that use
+  \pkg{Rcpp} to interface C++ code or libraries.
+}
+\details{
+  The \pkg{Rcpp} package provides a number of C++ classes that ease
+  access to C++ from R. This comprises both passing parameters to
+  functions, as well as returning results back from C++ to R.
+
+  Two APIs are supported. The first is an older API which was first
+  introduced mostly in 2006 and extended in 2008. This interface is used
+  by a few other packages and will be supported going forward.,
+  A second and newer API that was started in 2009 offers more
+  functionality.
+
+  The \pkg{RcppExamples} package provides some simple examples for use
+  of \pkg{Rcpp}. At this point the documentation is not complete in the
+  sense of not covering all accessible classes. However, several basic
+  use cases are illustrated,
+}
+\author{Dominick Samperi wrote the initial versions of Rcpp (and
+  RcppTemplate) during 2005 and 2006.  Dirk Eddelbuettel made some
+  additions, and became maintainer in 2008. Dirk Eddelbuettel and Romain
+  Francois have been extending Rcpp since 2009.
+}
+\keyword{package}
+

Modified: pkg/RcppExamples/man/RcppResultSet.Rd
===================================================================
--- pkg/RcppExamples/man/RcppResultSet.Rd	2010-03-05 18:14:12 UTC (rev 839)
+++ pkg/RcppExamples/man/RcppResultSet.Rd	2010-03-06 02:07:21 UTC (rev 840)
@@ -2,9 +2,10 @@
 \alias{RcppResultSet}
 \title{C++ class for sending C++ objects back to R}
 \description{
-  \code{RcppResultSet} is a C++ class defined in \code{Rcpp.h} that can
+  \code{RcppResultSet} is a C++ class defined in \code{RcppResultSet.h} that can
   assign any number of C++ objects to \R in a single named list object 
-  as the \code{SEXP} return value of a \code{.Call()} function call.
+  as the \code{SEXP} return value of a \code{.Call()} function call. It
+  is part of the classic API.
   
   The C++ objects can be of different types that are limited to 
   types  \code{double},  \code{int}, \code{string}, vectors of
@@ -23,6 +24,7 @@
   \code{integer}, or \code{character}.  The \code{C++} code can all be
   retrieved in \R as elements of a named list object.
 
+  The new API has more generic templated functions.
 }
 %\usage{
 %}
@@ -74,7 +76,6 @@
   The class member function \code{checkNames} can be used to verify that the
   \code{SEXP} object passed to the function contains a given set of
   named object.
-
 }
 %\references{
 %  See \code{Rcpp.h} and the package vignette.

Modified: pkg/RcppExamples/man/RcppVector.Rd
===================================================================
--- pkg/RcppExamples/man/RcppVector.Rd	2010-03-05 18:14:12 UTC (rev 839)
+++ pkg/RcppExamples/man/RcppVector.Rd	2010-03-06 02:07:21 UTC (rev 840)
@@ -10,9 +10,9 @@
 \title{C++ classes for receiving R object in C++}
 \description{
   \code{RcppVector}, \code{RcppMatrix} and \code{RcppStringVector} are
-  C++ classes defined in \code{Rcpp.h} that can
-  pass vectors (matrices) of \R objects of appropriate types to C++ via
-  the \code{.Call()} function interface. 
+  C++ classes that can pass vectors (matrices) of \R objects of
+  appropriate types to C++ via the \code{.Call()} function interface. 
+  They are part of the 'classic' Rcpp API. 
   
   The vector and matrix types are templated and can operate on \R types
   \code{intger} and \code{numeric}. 
@@ -24,6 +24,12 @@
   matrix object, convert it in a corresponding \code{C} representation,
   and also to convert it into a corresponding STL object.
 
+  The new API has classes \code{NumericVector}, \code{NumericMatrix},
+  \code{CharacterVector} (and also an alias \code{StringVector}).
+
+  The files \code{RcppVectorExample.cpp} and
+  \code{RcppMatrixExample.cpp} provide examples for both the classic and
+  new APIs.
 }
 %\usage{
 %}

Modified: pkg/RcppExamples/src/RcppStringVectorExample.cpp
===================================================================
--- pkg/RcppExamples/src/RcppStringVectorExample.cpp	2010-03-05 18:14:12 UTC (rev 839)
+++ pkg/RcppExamples/src/RcppStringVectorExample.cpp	2010-03-06 02:07:21 UTC (rev 840)
@@ -23,16 +23,25 @@
 
 #include <Rcpp.h>
 
+// local helper function to transform all characters of a given string
+void stringToLower(std::string & s) {
+    std::transform(s.begin(), s.end(), s.begin(), ::tolower);
+}
+
 RcppExport SEXP newRcppStringVectorExample(SEXP strvec) {
 
     Rcpp::StringVector orig(strvec);		// creates Rcpp string vector from SEXP
     Rcpp::StringVector vec(orig.size());	
 
+    std::string txt;
     for (int i=0; i<orig.size(); i++) {
-	std::string txt(orig[i]);
-	std::transform(txt.begin(), txt.end(), txt.begin(), ::tolower);
+	txt = orig[i];
+	stringToLower(txt);
 	vec[i] = txt;
     }
+    //std::transform(orig.begin(), orig.end(), vec.begin(), stringToLower);
+    //std::for_each(vec.begin(), vec.end(), stringToLower);
+    
 
     Rcpp::Pairlist res(Rcpp::Named( "result", vec),
                        Rcpp::Named( "original", orig));



More information about the Rcpp-commits mailing list