Learn R Programming

wrapr (version 1.0.1)

ateval: Evaluate an expression with @name substitution.

Description

The expression represented by the text of the .-argument is evaluated in the current environment will all "@name" forms replaced by the value of name. This allows variables to carry the names of other variables into what would be a non-standard evaluation situation. This adaption allows some parametric or standard-evaluation effects in such circumstances.

Usage

ateval(.)

Arguments

.

character text of expression or block to evaluate

Details

Note: this method uses string substitution and is willing to substitute in arbitrary content, please prefer using let where applicable.

Notation idea: Jonathan Carroll https://jcarroll.com.au https://twitter.com/carroll_jono/status/842142292253196290 Similar to: https://dev.mysql.com/doc/refman/5.7/en/user-variables.html.

See Also

let, beval, seval

Examples

Run this code
# NOT RUN {

c1 <- 1:5
c2 <- 3:7
col1 <- 'c1'
col2 <- 'c2'
new_col_name <- 'res'
ateval(
  '@new_col_name <- @col1 + @col2'
)
print(res)

# larger example
c3 <- 4:8
terms <- paste(c('c1', 'c2', 'c3'), collapse = ' + ')
print(ateval('@terms'))

# }

Run the code above in your browser using DataLab