powered by
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.
evalText(..., envir = parent.frame())
the result of the evaluation
the R code to evaluate as characters. Will be joined when evaluating.
the environment in which to evaluate the code. Defaults to the parent frame of the function.
# 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