[Rcpp-commits] r4009 - in pkg/Rcpp: . inst/doc/Rcpp-attributes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Nov 21 15:05:05 CET 2012


Author: jjallaire
Date: 2012-11-21 15:05:05 +0100 (Wed, 21 Nov 2012)
New Revision: 4009

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/inst/doc/Rcpp-attributes/Rcpp-attributes.Rnw
Log:
add section on package creation to attributes vignette

Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2012-11-21 13:34:00 UTC (rev 4008)
+++ pkg/Rcpp/ChangeLog	2012-11-21 14:05:05 UTC (rev 4009)
@@ -4,7 +4,8 @@
         parameters to Rcpp.pacakge.skeleton
         * inst/skeleton/rcpp_hello_world_attributes.cpp: version of hello world
         that uses attributes
-        * man/Rcpp.package.skeleton.Rd: documentation updates
+        * man/Rcpp.package.skeleton.Rd: doc updates
+        * inst/doc/Rcpp-attributes/Rcpp-attributes.Rnw: doc updates
 
 2012-11-21  Dirk Eddelbuettel  <edd at debian.org>
 

Modified: pkg/Rcpp/inst/doc/Rcpp-attributes/Rcpp-attributes.Rnw
===================================================================
--- pkg/Rcpp/inst/doc/Rcpp-attributes/Rcpp-attributes.Rnw	2012-11-21 13:34:00 UTC (rev 4008)
+++ pkg/Rcpp/inst/doc/Rcpp-attributes/Rcpp-attributes.Rnw	2012-11-21 14:05:05 UTC (rev 4009)
@@ -495,7 +495,7 @@
 
 \begin{enumerate}
 \item
-  Your code can be made availiable to users without \proglang{C++} development
+  Your code can be made available to users without \proglang{C++} development
   tools (at least on Windows or Mac OS X where binary packages are common)
 \item
   Multiple source files and their dependencies are handled automatically
@@ -505,10 +505,44 @@
   and consistency
 \end{enumerate}
 
-To build a package that is based on \pkg{Rcpp} you should first follow the 
-guidelines in the `\textsl{Rcpp-package}' vignette (for a new package this
-typically entails creating the package using \texttt{Rcpp.package.skeleton}).
+\subsection{Package Creation}
 
+To create a package that is based on \pkg{Rcpp} you should follow the 
+guidelines in the `\textsl{Rcpp-package}' vignette. For a new package this
+is most conveniently done using  the \texttt{Rcpp.package.skeleton} function.
+
+To generate a new package with a simple hello, world function that uses 
+attributes you can do the following:
+
+% \begin{verbatim}
+% > Rcpp.package.skeleton("NewPackage", attributes = TRUE)
+% \end{verbatim}
+\begin{kframe}
+\noindent
+\ttfamily
+\hlstd{}\hlopt{$>$\ }\hlstd{Rcpp}\hlopt{.}\hlstd{package}\hlopt{.}\hlstd{}\hlkwd{skeleton}\hlstd{}\hlopt{(}\hlstd{}\hlstr{"NewPackage"}\hlstd{}\hlopt{,\ }\hlstd{attributes\ }\hlopt{=\ }\hlstd{}\hlkwb{TRUE}\hlstd{}\hlopt{)}\hlstd{}\hspace*{\fill}
+\mbox{}
+\normalfont
+\normalsize
+\end{kframe}
+
+To generate a package based on \proglang{C++} files that you've been using
+with \texttt{sourceCpp} you can use the \texttt{cpp\_files} parameter:
+
+% \begin{verbatim}
+% > Rcpp.package.skeleton("NewPackage", example_code = FALSE,
+%                          cpp_files = c("convolve.cpp"))
+% \end{verbatim}
+\begin{kframe}
+\noindent
+\ttfamily
+\hlstd{}\hlopt{$>$\ }\hlstd{Rcpp}\hlopt{.}\hlstd{package}\hlopt{.}\hlstd{}\hlkwd{skeleton}\hlstd{}\hlopt{(}\hlstd{}\hlstr{"NewPackage"}\hlstd{}\hlopt{,\ }\hlstd{example\textunderscore code\ }\hlopt{=\ }\hlstd{}\hlkwb{FALSE}\hlstd{}\hlopt{,}\hspace*{\fill}\\
+\hlstd{}\hlstd{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ }\hlstd{cpp\textunderscore files\ }\hlopt{=\ }\hlstd{}\hlkwd{c}\hlstd{}\hlopt{(}\hlstd{}\hlstr{"convolve.cpp"}\hlstd{}\hlopt{))}\hlstd{}\hspace*{\fill}
+\mbox{}
+\normalfont
+\normalsize
+\end{kframe}
+
 \subsection{Exporting R Functions}
 
 Within interactive sessions you call the \texttt{sourceCpp} function
@@ -638,15 +672,13 @@
 \begin{enumerate}
 \item The generated R functions have an empty body. This is because they are 
 only present for binding to roxygen comments. A call to \texttt{Rcpp::loadModule}
-will replace the empty defintions with the appropriate \proglang{C++} functions.
+will replace the empty definitions with the appropriate \proglang{C++} functions.
 \item The functions do not include argument defaults since they are 
 not known at the time of generation. If you have argument defaults that you'd
 like included in the Rd usage section you can do this by adding an explicit
 \texttt{@usage} roxygen tag.
 \end{enumerate}
 
-\pagebreak
-
 \subsection{Providing a C++ Interface}
 
 The interface exposed from \proglang{R} packages is most typically a set of
@@ -723,8 +755,6 @@
 a custom one and still be able to include the automatically generated exports 
 (details on doing this are provided in the next section).
 
-\pagebreak
-
 The exported functions are defined within a \proglang{C++} namespace that matches
 the name of the package. For example, an exported \proglang{C++} function
 \texttt{bar} could be called from package \texttt{MyPackage} as follows:
@@ -801,8 +831,6 @@
 correctly. The recommended way to minimize binary compatibility problems is to
 only use built-in \proglang{C++} types and \pkg{Rcpp} wrapper types in your interfaces. 
 
-\pagebreak
-
 \bibliographystyle{plainnat}
 \bibliography{Rcpp}
 



More information about the Rcpp-commits mailing list