reduceexpand: Use function to reduce or expand arguments.

View source: R/Reduce.R

reduceexpandR Documentation

Use function to reduce or expand arguments.

Description

x %.|% f stands for f(x[[1]], x[[2]], ..., x[[length(x)]]). v %|.% x also stands for f(x[[1]], x[[2]], ..., x[[length(x)]]). The two operators are the same, the variation just allowing the user to choose the order they write things. The mnemonic is: "data goes on the dot-side of the operator."

Usage

f %|.% args

args %.|% f

Arguments

f

function.

args

argument list or vector, entries expanded as function arguments.

Details

Note: the reduce operation is implemented by do.call(), so has standard R named argument semantics.

Value

f(args) where args elements become individual arguments of f.

Functions

  • f %|.% args: f reduce args

  • args %.|% f: args expand f

See Also

do.call, list, c

Examples


args <- list('prefix_', c(1:3), '_suffix')
args %.|% paste0
# prefix_1_suffix" "prefix_2_suffix" "prefix_3_suffix"
paste0 %|.% args
# prefix_1_suffix" "prefix_2_suffix" "prefix_3_suffix"


WinVector/wrapr documentation built on Aug. 29, 2023, 4:51 a.m.