formula_tests: Testing functions for formulas

Description Usage Arguments Examples

Description

Provide facilities for checking the layout of formulas. Use these with an input that is the value of a formula, that is, with a V binding rather than an E binding.

Usage

1
2
3
4
5
6
7
8
9

Arguments

F

a formula from a student submission.

target

the desired attributes of the formula

...

expressions for the permissible parts of the formula

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
CODE <- for_checkr(quote({
   data(mtcars, package = "datasets")
   mod <- lm(mpg ~ hp * wt + cyl, data = mtcars)
   }))
fa <- formula_arg(line_calling(CODE, lm),
  failif(! two_sided(V), "Modeling formulas should have two sides."),
  failif(! lhs_equals(V, mpg), "The response variable should be mileage."))
# or, another style for the same thing ...
check(formula_arg(line_calling(CODE, lm)),
  failif(! two_sided(V), "Modeling formulas should have two sides."),
  failif(! lhs_equals(V, mpg), "The response variable should be mileage."))

dtkaplan/checkr documentation built on May 15, 2019, 4:59 p.m.