Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

partial

Partially apply a function


Description

Simplify a function by setting some arguments to pre-specified values

Usage

partial(f, ...)

Arguments

f

a function

...

arguments to capture

Author(s)

References

See Also

Examples

# Example 1:
f <- function(a, b, c, d) a+b+c+d
p <- partial(f, a=2, c=3)
p(b=0, d=1)

# captures a format string for printing out sleep data
labeller <- partial(sprintf, fmt="extra=%3.2f, group=%d, ID=%d")
do.call(labeller, sleep[1, , drop=FALSE])

stackoverflow

Stack Overflow's Greatest Hits

v0.7.0
CC BY-SA 4.0
Authors
Neal Fultz <nfultz@gmail.com> and the StackOverflow.com community
Initial release
2020-01-03

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.