Skip to contents

Check if input is syntactically valid R code

Usage

expect_r_code(object)

Arguments

object

A single string, possibly containing parse-able R code.

Value

Returns nothing but throws an error if the input is not valid R code.

Details

This helper does not attempt to evaluate the code in the provided string. Instead, it uses parse() to determine whether the string contains valid R syntax.

This expectation will fail if object contains any exposition surrounding the code, including if code is surrounded by backticks.