My usecase is as follows:
- Display GUI to collect some R expressions
- Generate a single source file containing my simulation framework, intermixed with the R expressions provided by the user
- Allow the user to generate the single source file. If any of the expressions specified by the user contain errors (syntax or runtime), I want to display these in a user-friendly way.
In short, I want to do something as follows:
myExpression <- "3 * 5" myExprParsed <- tryCatch( parse(myExpression), .... ) My question is very simple: does R have some construct like \Q \E in regex, fully quoting a text string from beginning to end ? It is not unlikely that myExpression will contain the " character, thereby introducing a syntax error. I do not want to write the text contents to a separate text file and use source().
=Example=
myExpression <- " XXXXXXX " where XXXXXX is paste("my random value is ", runif(3)) would amount to
myExpression <- " paste("my random value is ", runif(3)) " which would give a syntax error. I want something like
myExpression <- verbatim@ paste("my random value is ", runif(3)) @