If f <- function(x){x^2} and g <- function(x){x+1} it is a constant source of annoyance to me that “f+g” is not defined. Package vfunc allows you to do this.

Details

The package defines a single S4 class, vf. This has a single slot, .Data, of type function which means that vf objects inherit much of the behaviour of functions, but for which new methods (such as the Arith group of S4 generics) may be defined.

Author

Robin K. S. Hankin [aut, cre] (ORCID: <https://orcid.org/0000-0001-5982-0415>)

Maintainer: Robin K. S. Hankin <hankin.robin@gmail.com>

Documentation Index

Index: This package was not yet installed at build time.

Examples

f <- as.vf(function(x){x^2})

f + Sin
#> An object of class "vf"
#> function (...) 
#> {
#>     e1(...) + e2(...)
#> }
#> <bytecode: 0x55a96b72d848>
#> <environment: 0x55a96b722ac0>

as.function(f*Sin + Exp)(1:4)
#> [1]  3.559753 11.026246 21.355617 42.489310