@@ -144,7 +144,7 @@ NumericVector convolveCpp(NumericVector a, NumericVector b) {
144
144
The addition of the export attribute allows us to do this from the \proglang {R}
145
145
prompt:
146
146
147
- <<eval =FALSE >>=
147
+ <<eval =FALSE , lang = r >>=
148
148
sourceCpp(" convolve.cpp" )
149
149
convolveCpp(x , y )
150
150
@
@@ -173,7 +173,7 @@ DataFrame readData(
173
173
174
174
Will be exported to R as:
175
175
176
- <<lang =r >>=
176
+ <<eval = FALSE , lang =r >>=
177
177
function (file , colNames = character (), commentChar = " #" , header = TRUE )
178
178
@
179
179
@@ -365,7 +365,7 @@ There are several ways to accomplish this, including passing a code
365
365
string to \texttt {sourceCpp } or using the shorter-form \texttt {cppFunction }
366
366
or \texttt {evalCpp } functions. For example:
367
367
368
- <<lang =r >>=
368
+ <<eval = FALSE , lang =r >>=
369
369
cppFunction('
370
370
int fibonacci(const int x) {
371
371
if (x < 2)
@@ -380,7 +380,7 @@ evalCpp('std::numeric_limits<double>::max()')
380
380
381
381
You can also specify a depends parameter to \texttt {cppFunction } or \texttt {evalCpp }:
382
382
383
- <<lang =r >>=
383
+ <<eval = FALSE , lang =r >>=
384
384
cppFunction(depends = ' RcppArmadillo' , code = ' ...' )
385
385
@
386
386
@@ -412,14 +412,14 @@ is most conveniently done using the \texttt{Rcpp.package.skeleton} function.
412
412
To generate a new package with a simple hello, world function that uses
413
413
attributes you can do the following:
414
414
415
- <<lang =r >>=
415
+ <<eval = FALSE , lang =r >>=
416
416
Rcpp.package.skeleton(" NewPackage" , attributes = TRUE )
417
417
@
418
418
419
419
To generate a package based on \proglang {C++} files that you've been using
420
420
with \texttt {sourceCpp } you can use the \texttt {cpp\_ files } parameter:
421
421
422
- <<lang =r >>=
422
+ <<eval = FALSE , lang =r >>=
423
423
Rcpp.package.skeleton(" NewPackage" , example_code = FALSE ,
424
424
cpp_files = c(" convolve.cpp" ))
425
425
@
@@ -436,7 +436,7 @@ you need to add these entries.
436
436
For example, if your package depends on \pkg {Rcpp} and \pkg {RcppArmadillo}
437
437
you would have the following in your \texttt {DESCRIPTION } file:
438
438
439
- <<lang =sh >>=
439
+ <<lang =bash >>=
440
440
Depends : Rcpp (> = 0.10.0 ), RcppArmadillo (> = 0.3.4.4 )
441
441
LinkingTo : Rcpp , RcppArmadillo
442
442
@
@@ -452,7 +452,7 @@ The \texttt{compileAttributes} function scans the source files within a package
452
452
for export attributes and generates code as required. For example, executing
453
453
this from within the package working directory:
454
454
455
- <<eval =FALSE >>=
455
+ <<eval =FALSE , lang = r >>=
456
456
compileAttributes()
457
457
@
458
458
@@ -499,7 +499,7 @@ NumericVector strLength(CharacterVector str)
499
499
500
500
Results in the following code in the generated \proglang {R} source file:
501
501
502
- <<lang =r >>=
502
+ <<eval = FALSE , lang =r >>=
503
503
# ' The length of a string (in characters).
504
504
# '
505
505
# ' @param str input character vector
@@ -550,7 +550,7 @@ If you request a \texttt{cpp} interface for a source file then
550
550
(substituting \emph {Package } with the name of the package code is being
551
551
generated for):
552
552
553
- <<lang =sh >>=
553
+ <<lang =bash >>=
554
554
inst / include / Package.h
555
555
inst / include / Package_RcppExports.h
556
556
@
@@ -601,7 +601,7 @@ compilation of your package source files, you will also need to add the
601
601
following entry to \texttt {Makevars } and \texttt {Makevars.win } (both are
602
602
in the \texttt {src } directory of your package):
603
603
604
- <<lang =sh >>=
604
+ <<lang =bash >>=
605
605
PKG_CPPFLAGS + = - I.. / inst / include /
606
606
@
607
607
0 commit comments