[Rd] wishlist: functions to manipulate functions
deepayan.sarkar at gmail.com
Thu Mar 2 04:27:47 CET 2006
Even though R is a functional language and it's common to have
functions as arguments to other functions (notably lapply and
friends), it is not possible to manipulate functions as easily as
other objects. I particularly miss
1. An operator to combine functions (analogous to %*%), e.g.
which for instance could be used to do
sapply(ls(), class %of% get)
sapply(ls(), function(x) class(get(x)))
2. Something to create a new function from an old one with different
args <- list(...)
dots <- list(...)
dots[names(args)] <- args
This is probably more useful in lattice than elsewhere, e.g.
qqmath(rt(1000, df = 5), distribution = update(qt, df = 5))
qqmath(rt(1000, df = 5), distribution = function(p) qt(p, df = 5))
Would these be worth adding to the base system?
It would also have been cool if (sin^2 + cos^2) returned a valid
function, but defining Ops.function doesn't seem to have any effect
(probably because oldClass is NULL for functions).
More information about the R-devel