From 95ce4b45a1fe81294f812d5127b9551269affa88 Mon Sep 17 00:00:00 2001 From: John Mount Date: Fri, 24 Mar 2017 09:19:07 -0700 Subject: [PATCH] non-strict examples fix strict default --- R/atblock.R | 8 ++++++++ R/let.R | 7 +++++-- man/ateval.Rd | 4 ++++ man/beval.Rd | 4 ++++ man/let.Rd | 7 +++++-- 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/R/atblock.R b/R/atblock.R index 477a3399..b6375326 100644 --- a/R/atblock.R +++ b/R/atblock.R @@ -28,6 +28,10 @@ #' ) #' print(res) #' +#' # larger example +#' c3 <- 4:8 +#' terms <- paste(c('c1', 'c2', 'c3'), collapse = ' + ') +#' print(ateval('@terms')) #' #' @export #' @@ -92,6 +96,10 @@ ateval <- function(.) { #' ) #' print(res) #' +#' # larger example +#' c3 <- 4:8 +#' terms <- paste(c('c1', 'c2', 'c3'), collapse = ' + ') +#' print(beval((!!terms))) #' #' @export #' diff --git a/R/let.R b/R/let.R index 1f1e087d..d0316557 100644 --- a/R/let.R +++ b/R/let.R @@ -216,11 +216,14 @@ letprep <- function(alias, strexpr, strict) { #' #' # let works by string substitution aligning on word boundaries, #' # so it does (unfortunately) also re-write strings. -#' let(list(x='y'),'x') +#' let(list(x='y'), 'x') +#' +#' # let can also substitute arbitrary expressions if strict=FALSE +#' let(list(e='1+3'), e, strict= FALSE) #' #' @export let <- function(alias, expr, - strict= FALSE) { + strict= TRUE) { # try to execute expression in parent environment # string substitution based implementation exprS <- letprep(alias, deparse(substitute(expr)), diff --git a/man/ateval.Rd b/man/ateval.Rd index 3acb1d6f..5f636e27 100644 --- a/man/ateval.Rd +++ b/man/ateval.Rd @@ -33,5 +33,9 @@ ateval( ) print(res) +# larger example +c3 <- 4:8 +terms <- paste(c('c1', 'c2', 'c3'), collapse = ' + ') +print(ateval('@terms')) } diff --git a/man/beval.Rd b/man/beval.Rd index 20455728..b5cd8dfb 100644 --- a/man/beval.Rd +++ b/man/beval.Rd @@ -34,5 +34,9 @@ beval( ) print(res) +# larger example +c3 <- 4:8 +terms <- paste(c('c1', 'c2', 'c3'), collapse = ' + ') +print(beval((!!terms))) } diff --git a/man/let.Rd b/man/let.Rd index 25fea66d..580e7ea8 100644 --- a/man/let.Rd +++ b/man/let.Rd @@ -4,7 +4,7 @@ \alias{let} \title{Execute expr with name substitutions specified in alias.} \usage{ -let(alias, expr, strict = FALSE) +let(alias, expr, strict = TRUE) } \arguments{ \item{alias}{mapping from free names in expr to target names to use.} @@ -68,6 +68,9 @@ print(dres) # let works by string substitution aligning on word boundaries, # so it does (unfortunately) also re-write strings. -let(list(x='y'),'x') +let(list(x='y'), 'x') + +# let can also substitute arbitrary expressions if strict=FALSE +let(list(e='1+3'), e, strict= FALSE) }