[R] integrate with vector arguments

JS Huang
Fri, 27 Feb 2015 00:25:56 -0000

Hi,

  The following works.

> f2
function(z)
{
  f1 <- function(t)
  {
    z*t + z*t^2
  }
  return(f1)
}
> sapply(1:5,function(x)integrate(f2(x),0,1)$value)
[1] 0.8333333333 1.6666666667 2.5000000000 3.3333333333 4.1666666667



--
View this message in context:
http://r.789695.n4.nabble.com/integrate-with-vector-arguments-tp4703906p4703925.html
Sent from the R help mailing list archive at Nabble.com.