R - Checking if a string is a valid mathematical expression using non-standard evaluation
问题 I would like to check if the strings below are valid mathematical expressions: s1 = 'sin(x)' s2 = 'sin(x*m)' s3 = 'sin' s4 = 'sin(xm)' By 'valid', I mean the expression is a combination of operators (must be used in conjunction with variables or constants) variables x and/or m constants. By this definition s1 and s2 are valid while s3 and s4 are not. To identify if a string is valid, I wrote a function checkFxn that first attempts to convert the string into a call or one of its parts. If