Learn R Programming

FastUtils (version 0.2.1)

evalText: evaluates a string as R code, and stops if an error occurs

Description

This function evaluates a string as R code, and stops if an error occurs. This can be useful for evaluating code that is generated dynamically.

Usage

evalText(..., envir = parent.frame())

Value

the result of the evaluation

Arguments

...

the R code to evaluate as characters. Will be joined when evaluating.

envir

the environment in which to evaluate the code. Defaults to the parent frame of the function.

Examples

Run this code
# Set names of a vector
x <- 1:3
x <- evalText("setNames(x, c('A', 'B', 'C'))")
x

Run the code above in your browser using DataLab