zfunction() rearranges the arguments of any function moving the specified argument to the front of the list, so that this argument becomes the recipient of piping.

It returns a copy of the input function, that is completely identical except for the order of the arguments.

zfunction(fun, x)

Arguments

fun

The function to adapt. The name should not be quoted, rather, the actual function should be passed (prefixed with package if needed).

x

The name of the argument that should be moved to the front of the argument list . The name should not be quoted.

Examples


char_vector <- rownames(mtcars)

zgrep <- zfunction(grep, x)
grep("ll", char_vector, value=TRUE)
#> [1] "Cadillac Fleetwood" "Toyota Corolla"     "Dodge Challenger"  
zgrep(char_vector, "ll", value=TRUE)
#> [1] "Cadillac Fleetwood" "Toyota Corolla"     "Dodge Challenger"