Parse a string into an expression with SymPy's parser
Source:R/parsing-sympy-parser-eval.R
parse_expr.Rdparse_expr() is SymPy's parse_expr: the string is tokenized as
Python, rewritten by the token transformations (see
standard_transformations) and evaluated with SymPy's names. Unknown
names become symbols or undefined functions, numbers become exact
integers and floats, x! is a factorial and 0.[3] a repeating
decimal. With evaluate = FALSE the operators build unevaluated
expressions. sympify() is unchanged and does not use this parser.
Usage
parse_expr(
s,
local_dict = NULL,
transformations = standard_transformations,
global_dict = NULL,
evaluate = TRUE
)Arguments
- s
A character string.
- local_dict
A named list of names to use first.
- transformations
A list of token transformations, or
"all"or"implicit"for SymPy's groups of them.- global_dict
A named list to use instead of SymPy's names, or
NULL.- evaluate
If
FALSE, arithmetic and the elementary functions are left unevaluated.