grab_bindings: Grab any bindings from a pattern match

Description Usage Arguments Details Examples

Description

UNLIKE the check_ functions which return checkr_result objects, grab_bindings returns a list with the values matched to the keys.

Usage

1
2
3
4
grab_bindings(ex, ..., key_list = NULL, all_for_one = TRUE,
  one_for_all = FALSE)

grab_binding_anywhere(ex, key)

Arguments

ex

the expression to be searched for the patterns

...

the set of patterns. Each pattern must be be enclosed in quote(). See details.

key_list

specify a set of patterns as a list of quoted expressions, rather than putting them individually in ...

all_for_one

Logical. If TRUE, then there must be an expression that matches all patterns.

one_for_all

Logical. If TRUE, then all patterns must match at least one expression in ex.

key

for grab_bindings_anywhere(), a single pattern as a quoted expression

Details

The patterns in ... will often have internal commas. To distinquish these from separate arguments to grab_bindings(), each pattern must be quoted, e.g. quote(plot(.(one), .(two))). Note that the patterns should include assignment if there is to be any.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
ex <- for_checkr(quote(plot(mpg ~ wt, data = subset(mtcars, hp < 150))))
grab_bindings(ex, quote(.(fn)(.(formula), data = .(the_data))))
ex2 <- for_checkr(quote({x <- 1; y <- x^2}))
grab_bindings(ex2, quote(`<-`(x, ..(first))),
     quote(`<-`(.(var), .(fn)(x, .(exponent)))), all_for_one = FALSE)
grab_bindings(ex2, quote(`<-`(x, ..(first))),
      quote(`<-`(.(var), .(fn)(x, .(exponent)))))
grab_binding_anywhere(for_checkr(quote({4 - 7;sin(3 + 2)})), quote(`+`(.(a), .(b))))
grab_binding_anywhere(for_checkr(quote({4 - 7;sin(3 + 2)})), quote(.(fn)(3 + 2)))
grab_binding_anywhere(for_checkr(quote({4 - 7;sin(3 + 2)})), quote(`-`(.(a), .(b))))

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