Skip to content

Commit 584b89d

Browse files
committed
protect R snippets from evaluation by R during build
1 parent 24f9c7b commit 584b89d

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

vignettes/Rcpp-attributes.Rnw

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ NumericVector convolveCpp(NumericVector a, NumericVector b) {
144144
The addition of the export attribute allows us to do this from the \proglang{R}
145145
prompt:
146146

147-
<<eval=FALSE>>=
147+
<<eval=FALSE,lang=r>>=
148148
sourceCpp("convolve.cpp")
149149
convolveCpp(x, y)
150150
@
@@ -173,7 +173,7 @@ DataFrame readData(
173173

174174
Will be exported to R as:
175175

176-
<<lang=r>>=
176+
<<eval=FALSE,lang=r>>=
177177
function(file, colNames=character(), commentChar="#", header=TRUE)
178178
@
179179

@@ -365,7 +365,7 @@ There are several ways to accomplish this, including passing a code
365365
string to \texttt{sourceCpp} or using the shorter-form \texttt{cppFunction}
366366
or \texttt{evalCpp} functions. For example:
367367

368-
<<lang=r>>=
368+
<<eval=FALSE,lang=r>>=
369369
cppFunction('
370370
int fibonacci(const int x) {
371371
if (x < 2)
@@ -380,7 +380,7 @@ evalCpp('std::numeric_limits<double>::max()')
380380

381381
You can also specify a depends parameter to \texttt{cppFunction} or \texttt{evalCpp}:
382382

383-
<<lang=r>>=
383+
<<eval=FALSE,lang=r>>=
384384
cppFunction(depends = 'RcppArmadillo', code = '...')
385385
@
386386

@@ -412,14 +412,14 @@ is most conveniently done using the \texttt{Rcpp.package.skeleton} function.
412412
To generate a new package with a simple hello, world function that uses
413413
attributes you can do the following:
414414

415-
<<lang=r>>=
415+
<<eval=FALSE,lang=r>>=
416416
Rcpp.package.skeleton("NewPackage", attributes = TRUE)
417417
@
418418

419419
To generate a package based on \proglang{C++} files that you've been using
420420
with \texttt{sourceCpp} you can use the \texttt{cpp\_files} parameter:
421421

422-
<<lang=r>>=
422+
<<eval=FALSE,lang=r>>=
423423
Rcpp.package.skeleton("NewPackage", example_code = FALSE,
424424
cpp_files = c("convolve.cpp"))
425425
@
@@ -436,7 +436,7 @@ you need to add these entries.
436436
For example, if your package depends on \pkg{Rcpp} and \pkg{RcppArmadillo}
437437
you would have the following in your \texttt{DESCRIPTION} file:
438438

439-
<<lang=sh>>=
439+
<<lang=bash>>=
440440
Depends: Rcpp (>= 0.10.0), RcppArmadillo (>= 0.3.4.4)
441441
LinkingTo: Rcpp, RcppArmadillo
442442
@
@@ -452,7 +452,7 @@ The \texttt{compileAttributes} function scans the source files within a package
452452
for export attributes and generates code as required. For example, executing
453453
this from within the package working directory:
454454

455-
<<eval=FALSE>>=
455+
<<eval=FALSE,lang=r>>=
456456
compileAttributes()
457457
@
458458

@@ -499,7 +499,7 @@ NumericVector strLength(CharacterVector str)
499499

500500
Results in the following code in the generated \proglang{R} source file:
501501

502-
<<lang=r>>=
502+
<<eval=FALSE,lang=r>>=
503503
#' The length of a string (in characters).
504504
#'
505505
#' @param str input character vector
@@ -550,7 +550,7 @@ If you request a \texttt{cpp} interface for a source file then
550550
(substituting \emph{Package} with the name of the package code is being
551551
generated for):
552552

553-
<<lang=sh>>=
553+
<<lang=bash>>=
554554
inst/include/Package.h
555555
inst/include/Package_RcppExports.h
556556
@
@@ -601,7 +601,7 @@ compilation of your package source files, you will also need to add the
601601
following entry to \texttt{Makevars} and \texttt{Makevars.win} (both are
602602
in the \texttt{src} directory of your package):
603603

604-
<<lang=sh>>=
604+
<<lang=bash>>=
605605
PKG_CPPFLAGS += -I../inst/include/
606606
@
607607

0 commit comments

Comments
 (0)