fc: Generalized Function Composition and Partial Function...

Description Usage Arguments Details Value Examples

View source: R/fc.r

Description

'fc' is used to modify functions. It can be used to compose function with specified function parameters and it can be used to set parameter values (partial function evaluation).

Usage

1
fc(.func, ...)

Arguments

.func

the function to be modified.

...

the function modifiers (see Details).

Details

The 'fc' function works by capturing function modifier expressions in a list, which can be applied to the specified function via the 'do.call' function. The function make use of standard R evaluation only. The 'substitute' function is not used and modifiers expressions must be syntatically valid.

Value

A modified function based on the parameters provided.

Examples

1
2
3
4
5
6
7
8
9
# Partial function evaluation - a function that returns the first three
# elements of an object.
head3 <- fc(head, n=3)

# Function composition - a function that returns the fifth through the
# 10th element of an object using the head and tail functions.
head_1_to_10 <- fc(head, n=10)
head_5_to_10 <- fc(tail, x=head_1_to_10(x))
head_5_to_10(iris)

swang87/fc documentation built on Oct. 22, 2019, 1:37 a.m.