[Rcpp-commits] r3005 - in pkg/Rcpp: . inst inst/doc/Rcpp-FAQ

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Apr 19 15:46:10 CEST 2011


Author: edd
Date: 2011-04-19 15:46:09 +0200 (Tue, 19 Apr 2011)
New Revision: 3005

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/inst/NEWS
   pkg/Rcpp/inst/doc/Rcpp-FAQ/Rcpp-FAQ.Rnw
Log:
new FAQ example


Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2011-04-18 19:43:39 UTC (rev 3004)
+++ pkg/Rcpp/ChangeLog	2011-04-19 13:46:09 UTC (rev 3005)
@@ -1,3 +1,12 @@
+2011-04-19  Dirk Eddelbuettel  <edd at debian.org>
+
+	* inst/doc/Rcpp-FAQ/Rcpp-FAQ.Rnw: New example setting row and column
+	names for matrices
+
+2011-04-16  Dirk Eddelbuettel  <edd at debian.org>
+
+	* inst/doc/Rcpp-FAQ/Rcpp-FAQ.Rnw: New example using Rcpp.plugin.maker
+
 2011-04-12  Dirk Eddelbuettel  <edd at debian.org>
 
         * DESCRIPTION: Release 0.9.4

Modified: pkg/Rcpp/inst/NEWS
===================================================================
--- pkg/Rcpp/inst/NEWS	2011-04-18 19:43:39 UTC (rev 3004)
+++ pkg/Rcpp/inst/NEWS	2011-04-19 13:46:09 UTC (rev 3005)
@@ -1,3 +1,8 @@
+0.9.5   2011-xx-yy
+
+    o   New Rcpp-FAQ examples on using the plugin maker for inline's
+        cxxfunction(), and on setting row and column names for matrices
+
 0.9.4   2011-04-12
 
     o   New R function "loadRcppModules" to load Rcpp modules automatically

Modified: pkg/Rcpp/inst/doc/Rcpp-FAQ/Rcpp-FAQ.Rnw
===================================================================
--- pkg/Rcpp/inst/doc/Rcpp-FAQ/Rcpp-FAQ.Rnw	2011-04-18 19:43:39 UTC (rev 3004)
+++ pkg/Rcpp/inst/doc/Rcpp-FAQ/Rcpp-FAQ.Rnw	2011-04-19 13:46:09 UTC (rev 3005)
@@ -550,6 +550,32 @@
 Here the \pkg{Rcpp} function \code{Rcpp.plugin.maker} is used to create a
 plugin 'plug' which is then registered, and subsequently used by \pkg{inline}.
 
+\subsection{How can I set matrix row and column names ?}
+
+\begin{quote}
+  \emph{Ok, I can create a matrix, but how do I set its row and columns names?}
+\end{quote}
+
+Pretty much the same way as in \proglang{R} itself: We define a list with two
+character vectors, one each for row and column names, and assign this to the
+\code{dimnames} attribute:
+
+<<eval=FALSE>>=
+src <- '
+  Rcpp::NumericMatrix x(2,2);
+  x.fill(42);                           // or more interesting values
+  Rcpp::List dimnms =                   // two vec. with static names
+      Rcpp::List::create(Rcpp::CharacterVector::create("cc", "dd"),
+                         Rcpp::CharacterVector::create("ee", "ff"));
+  // and assign it
+  x.attr("dimnames") = dimnms;
+  return(x);
+'
+fun <- cxxfunction(signature(), body=src, plugin="Rcpp")
+fun()
+@
+%
+
 \section{Support}
 
 \subsection{Is the API documented ?}



More information about the Rcpp-commits mailing list