@@ -31,26 +31,26 @@ prettyDate <- format(Sys.Date(), "%B %e, %Y")
3131\date {\pkg {Rcpp} version \Sexpr{prettyVersion } as of \Sexpr{prettyDate } }
3232
3333
34- % % highlights macros
35- % % Style definition file generated by highlight 2.7, http://www.andre-simon.de/
36- % Highlighting theme definition:
37- \newcommand {\hlstd }[1]{\textcolor [rgb]{0,0,0}{#1}}
38- \newcommand {\hlnum }[1]{\textcolor [rgb]{0,0,0}{#1}}
34+ % % %% highlights macros
35+ % % %% Style definition file generated by highlight 2.7, http://www.andre-simon.de/
36+ % % % Highlighting theme definition:
37+ % % \newcommand{\hlstd}[1]{\textcolor[rgb]{0,0,0}{#1}}
38+ % % \newcommand{\hlnum}[1]{\textcolor[rgb]{0,0,0}{#1}}
3939\newcommand {\hlopt }[1]{\textcolor [rgb]{0,0,0}{#1}}
40- \newcommand {\hlesc }[1]{\textcolor [rgb]{0.74,0.55,0.55}{#1}}
41- % \newcommand{\hlstr}[1]{\textcolor[rgb]{0.74,0.55,0.55}{#1}}
42- \newcommand {\hlstr }[1]{\textcolor [rgb]{0.90,0.15,0.15}{#1}}
43- % green: \newcommand{\hlstr}[1]{\textcolor[rgb]{0.13,0.67,0.13}{#1}} % 0.74 -> % 0.90; 0.55 -> 0.25
44- \newcommand {\hldstr }[1]{\textcolor [rgb]{0.74,0.55,0.55}{#1}}
45- \newcommand {\hlslc }[1]{\textcolor [rgb]{0.67,0.13,0.13}{#1}}
46- \newcommand {\hlcom }[1]{\textcolor [rgb]{0.67,0.13,0.13}{#1}}
47- \newcommand {\hldir }[1]{\textcolor [rgb]{0,0,0}{#1}}
48- \newcommand {\hlsym }[1]{\textcolor [rgb]{0,0,0}{#1}}
49- \newcommand {\hlline }[1]{\textcolor [rgb]{0.33,0.33,0.33}{#1}}
50- \newcommand {\hlkwa }[1]{\textcolor [rgb]{0.61,0.13,0.93}{\bf {#1}}}
51- \newcommand {\hlkwb }[1]{\textcolor [rgb]{0.13,0.54,0.13}{#1}}
52- \newcommand {\hlkwc }[1]{\textcolor [rgb]{0,0,1}{#1}}
53- \newcommand {\hlkwd }[1]{\textcolor [rgb]{0,0,0}{#1}}
40+ % % \newcommand{\hlesc}[1]{\textcolor[rgb]{0.74,0.55,0.55}{#1}}
41+ % % % \newcommand{\hlstr}[1]{\textcolor[rgb]{0.74,0.55,0.55}{#1}}
42+ % % \newcommand{\hlstr}[1]{\textcolor[rgb]{0.90,0.15,0.15}{#1}}
43+ % % % green: \newcommand{\hlstr}[1]{\textcolor[rgb]{0.13,0.67,0.13}{#1}} % 0.74 -> % 0.90; 0.55 -> 0.25
44+ % % \newcommand{\hldstr}[1]{\textcolor[rgb]{0.74,0.55,0.55}{#1}}
45+ % % \newcommand{\hlslc}[1]{\textcolor[rgb]{0.67,0.13,0.13}{#1}}
46+ % % \newcommand{\hlcom}[1]{\textcolor[rgb]{0.67,0.13,0.13}{#1}}
47+ % % \newcommand{\hldir}[1]{\textcolor[rgb]{0,0,0}{#1}}
48+ % % \newcommand{\hlsym}[1]{\textcolor[rgb]{0,0,0}{#1}}
49+ % % \newcommand{\hlline}[1]{\textcolor[rgb]{0.33,0.33,0.33}{#1}}
50+ % % \newcommand{\hlkwa}[1]{\textcolor[rgb]{0.61,0.13,0.93}{\bf{#1}}}
51+ % % \newcommand{\hlkwb}[1]{\textcolor[rgb]{0.13,0.54,0.13}{#1}}
52+ % % \newcommand{\hlkwc}[1]{\textcolor[rgb]{0,0,1}{#1}}
53+ % % \newcommand{\hlkwd}[1]{\textcolor[rgb]{0,0,0}{#1}}
5454\definecolor {bgcolor}{rgb}{1,1,1}
5555\newcommand {\hlppc }[1]{\textcolor [rgb]{0,0.51,0}{#1}}
5656
@@ -84,7 +84,7 @@ prettyDate <- format(Sys.Date(), "%B %e, %Y")
8484 functions as callable from \proglang {R} and automatically generating the code
8585 required to invoke them. Attributes are intended to facilitate both interactive use
8686 of \proglang {C++} within \proglang {R} sessions as well as to support \proglang {R}
87- package development. The implementation of attributes is based on previous
87+ package development. The implementation of attributes is based on previous
8888 work in the \pkg {inline} package \citep {CRAN:inline }.
8989}
9090
@@ -128,12 +128,12 @@ functions include:
128128
129129Attributes can also be used for package development via the
130130\texttt {compileAttributes } function, which automatically generates
131- \texttt {extern "C" } and \texttt {.Call } wrappers for \proglang {C++}
131+ \texttt {extern "C" } and \texttt {.Call } wrappers for \proglang {C++}
132132functions within pacakges.
133133
134134\section {Using Attributes }
135135
136- Attributes are annotations that are added to C++ source files to provide
136+ Attributes are annotations that are added to C++ source files to provide
137137additional information to the compiler. \pkg {Rcpp} supports attributes
138138to indicate that C++ functions should be made available as R functions,
139139as well as to optionally specify additional build dependencies for source files.
@@ -219,7 +219,7 @@ prompt:
219219
220220We can now write \proglang {C++} functions using built-in \proglang {C++} types
221221and \pkg {Rcpp} wrapper types and then source them just as we would an
222- \proglang {R} script.
222+ \proglang {R} script.
223223
224224The \texttt {sourceCpp } function performs caching based on the last
225225modified date of the source file so as long as the source file does not
@@ -233,7 +233,7 @@ the following C++ function:
233233
234234% \begin{verbatim}
235235% DataFrame readData(
236- % CharacterVector file,
236+ % CharacterVector file,
237237% CharacterVector colNames = CharacterVector::create(),
238238% std::string commentChar = "#",
239239% bool header = true)
@@ -265,7 +265,7 @@ Will be exported to R as:
265265\normalsize
266266\end {kframe }
267267
268- Note that C++ rules for default arguments still apply: they must occur
268+ Note that C++ rules for default arguments still apply: they must occur
269269consecutively at the end of the function signature and (unlike R) can't rely
270270on the values of other arguments.
271271
@@ -275,18 +275,18 @@ Not all \proglang{C++} defualt argument values can be parsed into their
275275\begin {itemize }
276276\item
277277 String literals delimited by quotes (e.g. \texttt {"foo" })
278- \item
278+ \item
279279 Decimal numeric values (e.g. \texttt {10 } or \texttt {4.5 })
280280\item
281- Pre-defined constants including \texttt {true }, \texttt {false },
281+ Pre-defined constants including \texttt {true }, \texttt {false },
282282 \texttt {R\_ NilValue }, \texttt {NA\_ STRING }, \texttt {NA\_ INTEGER },
283283 \texttt {NA\_ REAL }, and \texttt {NA\_ LOGICAL }.
284284\item
285- Selected vector types (\texttt {CharacterVector }, \texttt {IntegerVector },
285+ Selected vector types (\texttt {CharacterVector }, \texttt {IntegerVector },
286286 and \texttt {NumericVector }) instantiated using the \texttt {::create }
287287 static member function.
288- \item
289- \texttt {Matrix } types instantiated using the \texttt {rows },
288+ \item
289+ \texttt {Matrix } types instantiated using the \texttt {rows },
290290 \texttt {cols } constructor.
291291\end {itemize }
292292
@@ -344,15 +344,15 @@ files. However, it's often convenient to bundle code from both languages into
344344a common source file that can be executed using single call to \texttt {sourceCpp }.
345345
346346To embed chunks of \proglang {R} code within a \proglang {C++}
347- source file you include the \proglang {R} code within a block comment that
347+ source file you include the \proglang {R} code within a block comment that
348348has the prefix of \texttt {/*** R }. For example:
349349
350350% \begin{verbatim}
351351% /*** R
352- %
352+ %
353353% # Call the fibonacci function defined in C++
354354% fibonacci(10)
355- %
355+ %
356356% */
357357% \end{verbatim}
358358\begin {kframe }
@@ -378,7 +378,7 @@ shared library and then source the embedded \proglang{R} code.
378378\subsection {Modifying Function Names }
379379
380380You can change the name of an exported function as it appears to \proglang {R} by
381- adding a name parameter to \texttt {Rcpp::export }. For example:
381+ adding a name parameter to \texttt {Rcpp::export }. For example:
382382
383383% \begin{verbatim}
384384% // [[Rcpp::export(".convolveCpp")]]
@@ -395,7 +395,7 @@ adding a name parameter to \texttt{Rcpp::export}. For example:
395395\end {kframe }
396396
397397Note that in this case since the specified name is prefaced by a \code {.} the exported R
398- function will be hidden.
398+ function will be hidden.
399399
400400\subsection {Function Requirements }
401401
@@ -407,24 +407,24 @@ requirements to be correctly handled:
407407 Be defined in the global namespace (i.e. not within a C++ namespace declaration)
408408\item
409409 Have a return type that is either void or compatible with \texttt {Rcpp::wrap }
410- and parameter types that are compatible with \texttt {Rcpp::as } (see sections
410+ and parameter types that are compatible with \texttt {Rcpp::as } (see sections
411411 3.1 and 3.2 of the `\textsl {Rcpp-introduction}' vignette for more details).
412412 \item
413413 Use fully qualified type names for the return value and all parameters.
414- Rcpp types may however appear without a namespace qualifier (i.e.
414+ Rcpp types may however appear without a namespace qualifier (i.e.
415415 \texttt {DataFrame } is okay as a type name but \texttt {std::string } must be
416- specified fully).
416+ specified fully).
417417\end {itemize }
418418
419419\subsection {Random Number Generation }
420420
421421\proglang {R} functions implemented in \proglang {C} or \proglang {C++} need
422- to be careful to surround use of internal random number geneneration routines
423- (e.g. \texttt {unif\_ rand }) with calls to \texttt {GetRNGstate } and
424- \texttt {PutRNGstate }.
422+ to be careful to surround use of internal random number geneneration routines
423+ (e.g. \texttt {unif\_ rand }) with calls to \texttt {GetRNGstate } and
424+ \texttt {PutRNGstate }.
425425
426- Within \pkg {Rcpp}, this is typically done using the \texttt {RNGScope } class.
427- However, this is not necessary for \proglang {C++} functions exported using
426+ Within \pkg {Rcpp}, this is typically done using the \texttt {RNGScope } class.
427+ However, this is not necessary for \proglang {C++} functions exported using
428428attributes because an \texttt {RNGScope } is established for them automatically.
429429Note that \pkg {Rcpp} implements \texttt {RNGScope } using a counter, so it's
430430still safe to execute code that may establish it's own \texttt {RNGScope } (such
@@ -517,7 +517,7 @@ and by invoking \pkg{inline} plugins if they are available for a package.
517517
518518Note that while the \texttt {Rcpp::depends } attribute establishes dependencies
519519for \texttt {sourceCpp }, it's important to note that if you include the same
520- source file in an \proglang {R} package these dependencies must still be
520+ source file in an \proglang {R} package these dependencies must still be
521521listed in the \texttt {Depends } and \texttt {LinkingTo } fields of the package
522522\texttt {DESCRIPTION } file.
523523
@@ -527,10 +527,10 @@ listed in the \texttt{Depends} and \texttt{LinkingTo} fields of the package
527527Maintaining C++ code in it's own source file provides several benefits including
528528the ability to use \proglang {C++} aware text-editing tools and straightforward
529529mapping of compilation errors to lines in the source file. However, it's also
530- possible to do inline declaration and execution of C++ code.
530+ possible to do inline declaration and execution of C++ code.
531531
532532There are several ways to accomplish this, including passing a code
533- string to \texttt {sourceCpp } or using the shorter-form \texttt {cppFunction }
533+ string to \texttt {sourceCpp } or using the shorter-form \texttt {cppFunction }
534534or \texttt {evalCpp } functions. For example:
535535
536536% \begin{verbatim}
@@ -600,11 +600,11 @@ moving code from a standalone \proglang{C++} source file to a package:
600600
601601\subsection {Package Creation }
602602
603- To create a package that is based on \pkg {Rcpp} you should follow the
603+ To create a package that is based on \pkg {Rcpp} you should follow the
604604guidelines in the `\textsl {Rcpp-package}' vignette. For a new package this
605605is most conveniently done using the \texttt {Rcpp.package.skeleton } function.
606606
607- To generate a new package with a simple hello, world function that uses
607+ To generate a new package with a simple hello, world function that uses
608608attributes you can do the following:
609609
610610% \begin{verbatim}
@@ -641,7 +641,7 @@ with \texttt{sourceCpp} you can use the \texttt{cpp\_files} parameter:
641641Once you've migrated \proglang {C++} code into a package, the dependencies for
642642source files are derived from the \texttt {Depends } and \texttt {LinkingTo } fields
643643in the package \texttt {DESCRIPTION } file rather than the \texttt {Rcpp::depends }
644- attribute. For every package you import C++ code from (including \pkg {Rcpp})
644+ attribute. For every package you import C++ code from (including \pkg {Rcpp})
645645you need to add these entries.
646646
647647For example, if your package depends on \pkg {Rcpp} and \pkg {RcppArmadillo}
@@ -664,7 +664,7 @@ LinkingTo:\ Rcpp,\ RcppArmadillo}\hspace*{\fill}
664664\subsection {Exporting R Functions }
665665
666666Within interactive sessions you call the \texttt {sourceCpp } function
667- on individual files to export \proglang {C++} functions into the global
667+ on individual files to export \proglang {C++} functions into the global
668668environment. However, for packages you call a single utility function to
669669export all \proglang {C++} functions within the package.
670670
@@ -696,13 +696,13 @@ Results in the generation of the following two source files:
696696 the \texttt {extern "C" } functions defined in \texttt {RcppExports.cpp }.
697697\end {itemize }
698698
699- You should re-run \texttt {compileAttributes } whenever functions are added,
699+ You should re-run \texttt {compileAttributes } whenever functions are added,
700700removed, or have their signatures changed.
701701
702702The \texttt {compileAttributes } function deals only with exporting
703- \proglang {C++} functions to \proglang {R}. If you want the functions to
704- additionally be publicly available from your package's namespace another
705- step may be required. Specifically, if your package \texttt {NAMESPACE } file
703+ \proglang {C++} functions to \proglang {R}. If you want the functions to
704+ additionally be publicly available from your package's namespace another
705+ step may be required. Specifically, if your package \texttt {NAMESPACE } file
706706does not use a pattern to export functions then you should add an explicit
707707entry to \texttt {NAMESPACE } for each R function you want publicly available.
708708
@@ -767,10 +767,10 @@ The interface exposed from \proglang{R} packages is most typically a set of
767767\proglang {R} functions. However, the \proglang {R} package system also provides
768768a mechanism to allow the exporting of \proglang {C} and \proglang {C++}
769769interfaces using package header files. This is based on the
770- \texttt {R\_ RegisterCCallable } and \texttt {R\_ GetCCallable } functions described in
770+ \texttt {R\_ RegisterCCallable } and \texttt {R\_ GetCCallable } functions described in
771771`\textsl {Writing R Extensions}' \citep {R:Extensions }.
772772
773- \proglang {C++} interfaces to a package are published within the
773+ \proglang {C++} interfaces to a package are published within the
774774top level \texttt {include } directory of the package (which within the package
775775source directory is located at \texttt {inst/include }). The \proglang {R} build
776776system automatically adds the required \texttt {include } directories for all
@@ -779,12 +779,12 @@ packages specified in the \texttt{LinkingTo} field of the package
779779
780780\subsubsection {Interfaces Attribute }
781781
782- The \texttt {Rcpp::interfaces } attribute can be used to automatically
782+ The \texttt {Rcpp::interfaces } attribute can be used to automatically
783783generate a header-only interface to your \proglang {C++} functions
784784within the \texttt {include } directory of your package.
785785
786786The \texttt {Rcpp::interfaces } attribute is specified on a per-source
787- file basis, and indicates which interfaces (\proglang {R}, \proglang {C++},
787+ file basis, and indicates which interfaces (\proglang {R}, \proglang {C++},
788788or both) should be provided for exported functions within the file.
789789
790790For example, the following specifies that both R and \proglang {C++} interfaces
@@ -809,7 +809,7 @@ is not included in a source file is to generate an R interface only.
809809\subsubsection {Generated Code }
810810
811811If you request a \texttt {cpp } interface for a source file then
812- \texttt {compileAttributes } generates the following header files
812+ \texttt {compileAttributes } generates the following header files
813813(substituting \emph {Package } with the name of the package code is being
814814generated for):
815815
@@ -827,14 +827,14 @@ inst/include/Package\textunderscore RcppExports.h}\hspace*{\fill}
827827\normalsize
828828\end {kframe }
829829
830- The \texttt {Package\_ RcppExports.h } file has inline definitions for all
830+ The \texttt {Package\_ RcppExports.h } file has inline definitions for all
831831exported \proglang {C++} functions that enable calling them using the
832- \texttt {R\_ GetCCallable } mechanism.
832+ \texttt {R\_ GetCCallable } mechanism.
833833
834834The \texttt {Package.h } file does nothing other than include the
835- \texttt {Package\_ RcppExports.h } header. This is done so
835+ \texttt {Package\_ RcppExports.h } header. This is done so
836836that package authors can replace the \texttt {Package.h } header with
837- a custom one and still be able to include the automatically generated exports
837+ a custom one and still be able to include the automatically generated exports
838838(details on doing this are provided in the next section).
839839
840840The exported functions are defined within a \proglang {C++} namespace that matches
@@ -869,23 +869,23 @@ the name of the package. For example, an exported \proglang{C++} function
869869\subsubsection {Including Additional Code }
870870
871871You might wish to use the \texttt {Rcpp::interfaces } attribute to generate
872- a part of your package's \proglang {C++} interface but also provide
873- additional custom \proglang {C++} code. In this case you
874- should replace the generated \texttt {Package.h } file with one of your own.
872+ a part of your package's \proglang {C++} interface but also provide
873+ additional custom \proglang {C++} code. In this case you
874+ should replace the generated \texttt {Package.h } file with one of your own.
875875
876876Note that the way \pkg {Rcpp} distinguishes user verses generated files is by checking
877877for the presence a special token in the file (if it's present then it's known
878878to be generated and thus safe to overwrite). You'll see this token at the top
879- of the generated \texttt {Package.h } file, be sure to remove it if you want
879+ of the generated \texttt {Package.h } file, be sure to remove it if you want
880880to provide a custom header.
881881
882- Once you've established a custom package header file, you need only include the
883- \texttt {Package\_ RcppExports.h } file within your header to make available
882+ Once you've established a custom package header file, you need only include the
883+ \texttt {Package\_ RcppExports.h } file within your header to make available
884884the automatically generated code alongside your own.
885885
886- If you need to include code from your custom header files within the
886+ If you need to include code from your custom header files within the
887887compilation of your package source files, you will also need to add the
888- following entry to \texttt {Makevars } and \texttt {Makevars.win } (both are
888+ following entry to \texttt {Makevars } and \texttt {Makevars.win } (both are
889889in the \texttt {src } directory of your package):
890890
891891% \begin{verbatim}
0 commit comments