[R] attribute and main value

Gerrit Draisma gdraisma at xs4all.nl
Mon Dec 29 16:32:39 CET 2014

Just a curiosity question:

In the documentation for the nlm procedure
a find this example of defining a function
with a gradient attribute:
      f <- function(x, a)
          res <- sum((x-a)^2)
          attr(res, "gradient") <- 2*(x-a)
I get the gradient with
but how do I get the function value it self?


More information about the R-help mailing list