[Rcpp-commits] r2977 - in pkg/RcppExamples: . man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Apr 8 16:54:57 CEST 2011


Author: edd
Date: 2011-04-08 16:54:57 +0200 (Fri, 08 Apr 2011)
New Revision: 2977

Modified:
   pkg/RcppExamples/DESCRIPTION
   pkg/RcppExamples/man/RcppDataFrame.Rd
Log:
expand manual page
move version to a fourth decimal to denote 'in progress' status


Modified: pkg/RcppExamples/DESCRIPTION
===================================================================
--- pkg/RcppExamples/DESCRIPTION	2011-04-08 14:32:00 UTC (rev 2976)
+++ pkg/RcppExamples/DESCRIPTION	2011-04-08 14:54:57 UTC (rev 2977)
@@ -1,6 +1,6 @@
 Package: RcppExamples
 Title: Examples using Rcpp to interface R and C++ 
-Version: 0.1.2
+Version: 0.1.2.1
 Date: $Date$
 Author: Dirk Eddelbuettel and Romain Francois, based on code written 
  during 2005 and 2006 by Dominick Samperi 

Modified: pkg/RcppExamples/man/RcppDataFrame.Rd
===================================================================
--- pkg/RcppExamples/man/RcppDataFrame.Rd	2011-04-08 14:32:00 UTC (rev 2976)
+++ pkg/RcppExamples/man/RcppDataFrame.Rd	2011-04-08 14:54:57 UTC (rev 2977)
@@ -10,7 +10,35 @@
 }
 \details{
   Usage of \code{Rcpp::DataFrame} is fully defined in
-  the respective header file. 
+  the respective header file.
+
+  The C++ source file corresponding to the this function does the
+  following (inside of a \code{try/catch} block):
+
+  \preformatted{%
+      // construct the data.frame object
+      Rcpp::DataFrame DF = Rcpp::DataFrame(Dsexp);
+
+      // and access each column by name
+      Rcpp::IntegerVector a = DF["a"];
+      Rcpp::CharacterVector b = DF["b"];
+      Rcpp::DateVector c = DF["c"];
+      
+      // do something
+      a[2] = 42;
+      b[1] = "foo";
+      c[0] = c[0] + 7;                      // move up a week
+
+      // create a new data frame
+      Rcpp::DataFrame NDF = 
+	  Rcpp::DataFrame::create(Rcpp::Named("a")=a,
+				  Rcpp::Named("b")=b,
+				  Rcpp::Named("c")=c);
+
+      // and return old and new in list
+      return(Rcpp::List::create(Rcpp::Named("origDataFrame")=DF,
+				Rcpp::Named("newDataFrame")=NDF));
+  }
 }
 \author{Dirk Eddelbuettel and Romain Francois}
 \examples{



More information about the Rcpp-commits mailing list