From 5849e56791e4322d0867b178a2d0b8afdfff69e5 Mon Sep 17 00:00:00 2001 From: JJ Allaire Date: Sat, 1 Feb 2014 09:28:48 -0500 Subject: [PATCH] Embedded R code chunks in sourceCpp can now be disabled --- ChangeLog | 5 +++++ R/Attributes.R | 3 ++- inst/NEWS.Rd | 1 + man/sourceCpp.Rd | 7 +++++-- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index ff95645bb..e28817e9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-02-01 JJ Allaire + + * R/Attributes.R: Embedded R code chunks in sourceCpp can + now be disabled + 2014-01-31 Dirk Eddelbuettel * vignettes/Rcpp-FAQ.Rnw: Render code with background boxen diff --git a/R/Attributes.R b/R/Attributes.R index 18bf6c5a8..19c2ff607 100644 --- a/R/Attributes.R +++ b/R/Attributes.R @@ -20,6 +20,7 @@ sourceCpp <- function(file = "", code = NULL, env = globalenv(), + embeddedR = TRUE, rebuild = FALSE, showOutput = verbose, verbose = getOption("verbose")) { @@ -169,7 +170,7 @@ sourceCpp <- function(file = "", } # source the embeddedR - if (length(context$embeddedR) > 0) { + if (embeddedR && (length(context$embeddedR) > 0)) { srcConn <- textConnection(context$embeddedR) setwd(rWorkingDir) # will be reset by previous on.exit handler source(file=srcConn, echo=TRUE) diff --git a/inst/NEWS.Rd b/inst/NEWS.Rd index 0d21ebc3a..fbf0b96aa 100644 --- a/inst/NEWS.Rd +++ b/inst/NEWS.Rd @@ -33,6 +33,7 @@ \itemize{ \item Embedded R code chunks in sourceCpp are now executed within the working directory of the C++ source file. + \item Embedded R code chunks in sourceCpp can now be disabled. } \item Changes in Rcpp documentation: \itemize{ diff --git a/man/sourceCpp.Rd b/man/sourceCpp.Rd index 38e1a7e42..6f2bfa392 100644 --- a/man/sourceCpp.Rd +++ b/man/sourceCpp.Rd @@ -9,8 +9,8 @@ and RCPP_MODULE declarations. A shared library is then built and its exported fu } \usage{ sourceCpp(file = "", code = NULL, env = globalenv(), - rebuild = FALSE, showOutput = verbose, - verbose = getOption("verbose")) + embeddedR = TRUE, rebuild = FALSE, + showOutput = verbose, verbose = getOption("verbose")) } \arguments{ \item{file}{ @@ -21,6 +21,9 @@ sourceCpp(file = "", code = NULL, env = globalenv(), } \item{env}{ Environment where the R functions and modules should be made available. +} + \item{embeddedR}{ + \code{TRUE} to run embedded R code chunks. } \item{rebuild}{ Force a rebuild of the shared library.