wrapr::let()
is designed to get several important corner cases correct: including substitutions that are disjoint from the expression and symbol swaps.
library("wrapr")
<- 1
X <- 2
Y
let(
c(),
debugPrint = TRUE,
+ Y
X )
## list()
## X + Y
## [1] 3
let(
c(),
debugPrint = TRUE,
subsMethod = 'langsubs',
+ Y
X )
## list()
## X + Y
## [1] 3
let(
c(),
debugPrint = TRUE,
subsMethod = 'stringsubs',
+ Y
X )
## list()
## X + Y
## [1] 3
let(
c(),
debugPrint = TRUE,
subsMethod = 'subsubs',
+ Y
X )
## list()
## X + Y
## [1] 3
library("wrapr")
<- 1
X <- 2
Y
let(
c(X='Y', Y='X'),
debugPrint = TRUE,
+ Y
X )
## $X
## [1] "Y"
##
## $Y
## [1] "X"
##
## Y + X
## [1] 3
let(
c(X='Y', Y='X'),
debugPrint = TRUE,
subsMethod = 'langsubs',
+ Y
X )
## $X
## [1] "Y"
##
## $Y
## [1] "X"
##
## Y + X
## [1] 3
let(
c(X='Y', Y='X'),
debugPrint = TRUE,
subsMethod = 'stringsubs',
+ Y
X )
## $X
## [1] "Y"
##
## $Y
## [1] "X"
##
## expression(Y + X)
## [1] 3
let(
c(X='Y', Y='X'),
debugPrint = TRUE,
subsMethod = 'subsubs',
+ Y
X )
## $X
## [1] "Y"
##
## $Y
## [1] "X"
##
## Y + X
## [1] 3