grapes-in_block-grapes: Inline let-block notation.

%in_block%R Documentation

Inline let-block notation.

Description

Inline version of let-block.

Usage

a %in_block% b

Arguments

a

(left argument) named character vector with target names as names, and replacement names as values.

b

(right argument) expression or block to evaluate under let substitution rules.

Value

evaluated block.

See Also

let

Examples


d <- data.frame(
  Sepal_Length=c(5.8,5.7),
  Sepal_Width=c(4.0,4.4),
  Species='setosa')

# let-block notation
let(
  qc(
    AREA_COL = Sepal_area,
    LENGTH_COL = Sepal_Length,
    WIDTH_COL = Sepal_Width
  ),
  d %.>%
    transform(., AREA_COL = LENGTH_COL * WIDTH_COL)
)

# %in_block% notation
qc(
  AREA_COL = Sepal_area,
  LENGTH_COL = Sepal_Length,
  WIDTH_COL = Sepal_Width
) %in_block% {
  d %.>%
    transform(., AREA_COL = LENGTH_COL * WIDTH_COL)
}

# Note: in packages can make assignment such as:
#   AREA_COL <- LENGTH_COL <- WIDTH_COL <- NULL
# prior to code so targets don't look like unbound names.


wrapr documentation built on Aug. 20, 2023, 1:08 a.m.