@@ -87,11 +87,11 @@ vignette: >
8787
8888# Getting started
8989
90- ## How do I get started
90+ ## How do I get started
9191
9292If you have \pkg{Rcpp} installed, please execute the following command
9393in \proglang{R} to access the introductory vignette (which is a
94- variant of the \citet{JSS: Rcpp } and \citet{PeerJ: Rcpp } papers) for a
94+ variant of the \citet{JSS: Rcpp } and \citet{PeerJ: Rcpp ,TAS : Rcpp } papers) for a
9595detailed introduction, ideally followed by at least the Rcpp
9696Attributes \citep{CRAN:Rcpp: Attributes } vignette:
9797
@@ -104,7 +104,7 @@ vignette("Rcpp-attributes")
104104If you do not have \pkg{Rcpp} installed, these documents should also be available
105105whereever you found this document, \textsl{i.e.,} on every mirror site of CRAN.
106106
107- ## What do I need
107+ ## What do I need
108108
109109Obviously, \proglang{R} must be installed. \pkg{Rcpp} provides a
110110\proglang{C++} API as an extension to the \proglang{R} system. As such, it
@@ -125,7 +125,7 @@ means one needs:
125125Also see the [ RStudio documentation] ( http://www.rstudio.com/ide/docs/packages/prerequisites )
126126on pre-requisites for R package development.
127127
128- ## What compiler can I use
128+ ## What compiler can I use
129129
130130On almost all platforms, the GNU Compiler Collection (or ` gcc ` , which
131131is also the name of its \proglang{C} language compiler) has to be used along
@@ -250,7 +250,7 @@ Template Library to sum the elements of a numeric vector.
250250fx <- cxxfunction(signature(x = "numeric"),
251251 'NumericVector xx(x);
252252 return wrap(
253- std::accumulate(xx.begin(),
253+ std::accumulate(xx.begin(),
254254 xx.end(),
255255 0.0)
256256 );',
@@ -277,7 +277,7 @@ the code in a character string in R. This is easily achieved by using
277277
278278``` {r, eval=FALSE}
279279fx <- cxxfunction(signature(),
280- paste(readLines("myfile.cpp"),
280+ paste(readLines("myfile.cpp"),
281281 collapse="\n"),
282282 plugin = "Rcpp")
283283```
@@ -411,7 +411,7 @@ either approach takes care of a lot of these tedious and error-prone manual
411411steps.
412412
413413
414- ## But R CMD SHLIB still does not work
414+ ## But R CMD SHLIB still does not work
415415
416416We have had reports in the past where build failures occurred when users had
417417non-standard code in their ` ~/.Rprofile ` or ` Rprofile.site ` (or
@@ -422,7 +422,7 @@ invocation of `Rscript -e "..."` (as in \faq{using-r-cmd-shlib}
422422above) to retrieve settings directly from \pkg{Rcpp} will fail.
423423
424424You may need to uncomment such non-standard code, or protect it by wrapping
425- it inside ` if (interactive()) ` , or possibly try to use
425+ it inside ` if (interactive()) ` , or possibly try to use
426426` Rscript --vanilla ` instead of plain ` Rscript ` .
427427
428428## What about ` LinkingTo `
@@ -688,7 +688,7 @@ will even run the R part at the end.
688688template <typename T> class square :
689689 public std::unary_function<T,T> {
690690 public:
691- T operator()( T t) const {
691+ T operator()( T t) const {
692692 return t* t ;
693693 }
694694};
@@ -757,7 +757,7 @@ writeLines(a, file = "myfile.cpp")
757757If stored in a file ` myfile.cpp ` , we can use it via \pkg{inline}:
758758
759759``` {r, eval = FALSE}
760- fx <- cxxfunction(signature(x_="numeric",
760+ fx <- cxxfunction(signature(x_="numeric",
761761 Y_="matrix",
762762 z_="numeric" ),
763763 paste(readLines("myfile.cpp"),
@@ -838,7 +838,7 @@ random variable distributed as $N(m,s)$.
838838Using Rcpp Attributes, this can be as simple as
839839
840840``` {r, eval = FALSE}
841- cppFunction('Rcpp::NumericVector ff(int n) {
841+ cppFunction('Rcpp::NumericVector ff(int n) {
842842 return rnorm(n, 0, 100); }')
843843set.seed(42)
844844ff(5)
@@ -992,10 +992,10 @@ values instead.
992992``` {r, eval=FALSE}
993993myplugin <- getPlugin("Rcpp")
994994myplugin$env$PKG_CXXFLAGS <- "-std=c++11"
995- f <- cxxfunction(signature(),
995+ f <- cxxfunction(signature(),
996996 settings = myplugin, body = '
997997 // fails without -std=c++0x
998- std::vector<double> x = { 1.0, 2.0, 3.0 };
998+ std::vector<double> x = { 1.0, 2.0, 3.0 };
999999 return Rcpp::wrap(x);
10001000')
10011001f()
@@ -1025,7 +1025,7 @@ src <- '
10251025 x.attr("dimnames") = dimnms;
10261026 return(x);
10271027'
1028- fun <- cxxfunction(signature(),
1028+ fun <- cxxfunction(signature(),
10291029 body=src, plugin="Rcpp")
10301030fun()
10311031```
@@ -1156,13 +1156,13 @@ void sample_defaults(
11561156 NumericVector x =
11571157 NumericVector::create(), // Size 0 vector
11581158 bool bias = true, // Set to true
1159- std::string method =
1159+ std::string method =
11601160 "rcpp rules!") { // Set string
1161-
1161+
11621162 Rcpp::Rcout << "x size: " << x.size() << ", ";
11631163 Rcpp::Rcout << "bias value: " << bias << ", ";
11641164 Rcpp::Rcout << "method value: " << ".";
1165-
1165+
11661166}
11671167
11681168/*** R
@@ -1212,7 +1212,7 @@ conda install gxx_linux-64
12121212
12131213helps within this environment as it installs the corresponding
12141214` x86_64-conda_cos6-linux-gnu-c++ ` compiler. Documentation for this and other
1215- systems is provided
1215+ systems is provided
12161216[ at this page] ( https://conda.io/docs/user-guide/tasks/build-packages/compiler-tools.html ) .
12171217
12181218# Support
@@ -1416,12 +1416,12 @@ To illustrate this phenomenon, consider the following scenario:
14161416// [[Rcpp::export]]
14171417Rcpp::NumericVector const_override_ex (
14181418 const Rcpp::NumericVector& X) {
1419-
1419+
14201420 Rcpp::NumericVector Y(X); // Create object
14211421 // from SEXP
1422-
1422+
14231423 Y = Y * 2; // Modify new object
1424-
1424+
14251425 return X; // Return old object
14261426}
14271427```
@@ -1454,10 +1454,10 @@ the aforementioned approach is emphasized:
14541454// [[Rcpp::export]]
14551455std::string explicit_string_conv (
14561456 Rcpp::CharacterVector X) {
1457-
1457+
14581458 std::string s; // define storage
14591459 s = X[0]; // assign from CharacterVector
1460-
1460+
14611461 return s;
14621462}
14631463```
@@ -1467,8 +1467,8 @@ e.g. `std::string s = X[0]`, this would result in the compiler triggering
14671467a conversion error on _some_ platforms. The error would be similar to:
14681468
14691469```{bash, eval = FALSE}
1470- error: no viable conversion from 'Proxy'
1471- (aka 'string_proxy<16>') to 'std::string'
1470+ error: no viable conversion from 'Proxy'
1471+ (aka 'string_proxy<16>') to 'std::string'
14721472(aka 'basic_string<char, char_traits<char>,
14731473allocator<char> >')
14741474```
@@ -1501,14 +1501,14 @@ via `operator=`, then the resulting `Vector` would have a length of
15011501// [[Rcpp::export]]
15021502void vec_scalar_assign (int n, double fill_val) {
15031503 Rcpp::NumericVector X(n);
1504- Rcpp::Rcout << "Value of Vector " <<
1505- "on Creation: " <<
1504+ Rcpp::Rcout << "Value of Vector " <<
1505+ "on Creation: " <<
15061506 std::endl << X << std::endl;
1507-
1507+
15081508 X = fill_val;
1509-
1509+
15101510 Rcpp::Rcout << "Value of Vector " <<
1511- "after Assignment: " <<
1511+ "after Assignment: " <<
15121512 std::endl << X << std::endl;
15131513}
15141514```
@@ -1535,9 +1535,9 @@ void mat_scalar_assign(int n, double fill_val) {
15351535 Rcpp::Rcout << "Value of Matrix " <<
15361536 "on Creation: " <<
15371537 std::endl << X << std::endl;
1538-
1538+
15391539 X = fill_val;
1540-
1540+
15411541 Rcpp::Rcout << "Value of Matrix " <<
15421542 "after Assignment: " <<
15431543 std::endl << X << std::endl;
@@ -1612,7 +1612,7 @@ adequately for the majority of \pkg{Rcpp} data types. The notable exception
16121612that makes what would otherwise be a universal quantifier into an existential
16131613quantifier is the ` CharacterVector ` data type. Chiefly, the issue with
16141614sorting strings is related to how the ` CharacterVector ` relies upon the
1615- use of ` Rcpp::internal::string_proxy ` .
1615+ use of ` Rcpp::internal::string_proxy ` .
16161616In particular, ` Rcpp::internal::string_proxy ` is _ not_ MoveAssignable since the
16171617left hand side of ` operator=(const string_proxy \&rhs) ` is _ not_
16181618viewed as equivalent to the right hand side before the
@@ -1633,20 +1633,20 @@ approach alongside the problematic STL approach:
16331633// [[Rcpp::export]]
16341634Rcpp::CharacterVector preferred_sort (
16351635 Rcpp::CharacterVector x) {
1636-
1636+
16371637 Rcpp::CharacterVector y = Rcpp::clone(x);
16381638 y.sort();
1639-
1639+
16401640 return y;
16411641}
16421642
16431643// [[ Rcpp::export]]
16441644Rcpp::CharacterVector stl_sort(
16451645 Rcpp::CharacterVector x) {
1646-
1646+
16471647 Rcpp::CharacterVector y = Rcpp::clone(x);
16481648 std::sort(y.begin(), y.end());
1649-
1649+
16501650 return y;
16511651}
16521652```
@@ -1699,7 +1699,7 @@ sort(x)
16991699rcpp_sort(x)
17001700```
17011701
1702- ## Package building fails with 'symbols not found'
1702+ ## Package building fails with 'symbols not found'
17031703
17041704R 3.4.0 and later strongly encourage registering dynamically loadable
17051705symbols. In the stronger form (where ` .registration=TRUE ` is added to the
@@ -1722,4 +1722,3 @@ elsewhere.
17221722So if your autogenerated file fails, and a ` symbols not found ` error is reported
17231723by the linker, consider running ` compileAttributes() ` twice. Deleting
17241724` R/RcppExports.R ` and ` src/RcppExports.cpp ` may also work.
1725-
0 commit comments