Parse {svMisc} | R Documentation |
Parse R instructions provided as a string and return the expression if it is correct, or an object of class 'try-error' if it is an incorrect code, or NA if the (last) instruction is incomplete.
Parse(text)
text |
The character string vector to parse |
Returns an expression with the parsed code or NA
if the last
instruction is correct but incomplete, or an object of class'try-error' with
the error message if the code is incorrect.
On the contrary to parse()
, Parse()
recovers from incorrect code
and also detects incomplete code or strings.
Philippe Grosjean (phgrosjean@sciviews.org)
Parse('1+1') Parse('1+1; log(10)') # incomplete instruction Parse('log(') # incomplete string Parse('text <- "some text') # wrong instruction Parse('log)')