Skip to content
Prev 27258 / 63424 Next

as.function()

Antonio


thanks for your help here, but it doesn't answer my question.

Perhaps if I outline my motivation it would help.


I want to recreate the ability of
the "polynom" package to do the following:


 > library(polynom)
 > p <- polynomial(1:4)
 > p
1 + 2*x + 3*x^2 + 4*x^3
 > MySpecialFunction <- as.function(p)
 > MySpecialFunction(1:10)
  [1]   10   49  142  313  586  985 1534 2257 3178 4321
 > p <- 4
 > MySpecialFunction(1:10)
  [1]   10   49  142  313  586  985 1534 2257 3178 4321
 >


See how the user can define object "MySpecialFunction",
  which outlives short-lived polynomial "p".

Unfortunately, I don't see a way to modify as.function.polynomial()
to do what I want.


best wishes


rksh
On 14 Jan 2008, at 08:45, Antonio, Fabio Di Narzo wrote:

            
--
Robin Hankin
Uncertainty Analyst and Neutral Theorist,
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743