powered by
Try to parse() the code and see if an error occurs.
parse()
valid_syntax(code, silent = TRUE)
TRUE if the code could be parsed, otherwise FALSE.
TRUE
FALSE
A character vector of R source code.
Whether to suppress the error message when the code is not valid.
xfun::valid_syntax("1+1") xfun::valid_syntax("1+") xfun::valid_syntax(c("if(T){1+1}", "else {2+2}"), silent = FALSE)
Run the code above in your browser using DataLab