Inline version of let
-block.
a %in_block% b
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. |
evaluated block.
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) )#> Sepal_Length Sepal_Width Species Sepal_area #> 1 5.8 4.0 setosa 23.20 #> 2 5.7 4.4 setosa 25.08# %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) }#> Sepal_Length Sepal_Width Species Sepal_area #> 1 5.8 4.0 setosa 23.20 #> 2 5.7 4.4 setosa 25.08# 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.