[R] integrate function

Berend Hasselman bhh at xs4all.nl
Sun Dec 6 08:31:08 CET 2009




li li-13 wrote:
> 
> Yes, f2 is the function I wanted to write. I tried to do use "Vectorize"
> function to f1, it did not work.
>> f2 <- function(x)
> +      {
> +      integrate(Vectorize(f1,vectorize.args =p), lower=0,upper=1, x)
> +       }
>> f2(c(2,3))
> Error in Vectorize(f1, vectorize.args = p) :
>   must specify formal argument names to vectorize
> 

Use  integrate(Vectorize(f1,vectorize.args =c("p")), lower=0,upper=1, x) 

vectorize.args is a character vector of arguments according to the
documentation.

Then f2(1:3) will give:  19 with absolute error < 2.1e-13

Berend
-- 
View this message in context: http://n4.nabble.com/integrate-function-tp949420p949533.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list