Safely evaluating arithmetic expressions in R?
Edit Ok, since there seems to be a lot of confusion, I'm going to simplify the question a little. You can try to answer the original question below, or you can tackle this version instead and ignore everything below the line. My goal is to take an arbitrary expression and evaluate it in an extremely restricted environment. This environment will contain only variables with the following types of values: Numeric vectors Pure functions that take one or more numeric vectors and return numeric vectors (i.e. arithmetic operators) In addition, the expression would necessarily be able to use any