Hi, I'm not entirely sure what you want to calculate.
If you want to integrate by u in the interval from 0 to 4 for every value of x I would suggest something like this: x <- rnorm(10,0,1) f <- function(u,x){ exp((x-u)) } sapply(x, function(i){ integrate(f,lower=1,upper=4, x=i)$value }) You can just pass additional arguments to f to integrate, integrate always integrates by the first argument of the function passed as its first argument, see the help entry of integrate for more details. Best Regards, Tobias On Sun, 2018-10-21 at 12:02 +0000, malika yassa via R-help wrote: > hello > please you help me i have this functionx<-rnorm(10,0,1)f<-fuction(u,x) > {exp((x-u)}I want to calculate the integral of this function for each value > of x{for(i in 1:lenght(x)integrate(f,lower=1,upper=4) > thinks > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.