Hi first of all few comments
Does your email client have subject line? If yes please use it, if not, change the client. Please do not post in HTML, such emails have big chance to be scrambled. # this gives you 10 random numbers x<-rnorm(10,0,1) f<-fuction(u,x) {exp(x- u)} # you probably ment f<-function(u,x) {exp(x- u)} for(i in 1:lenght(x) integrate(f,lower=1,upper=4) # you probably ment for(i in 1:length(x)) integrate(f,lower=1,upper=4) ......................^^...^ but this gives you an error > for(i in 1:length(x)) integrate(f,lower=1,upper=4) Error in f(x, ...) : argument "x" is missing, with no default The error message comes from your f function as you did not defined u If you changed your f function somehow f<-function(x, u=2) {exp(x - u)} for(i in 1:length(x)) integrate(f,lower=1,upper=4) the error is gone but so do results. You need either print your results explicitly or to assign them to some object. But if you printed your results you would find that you get same repeated result length(x) times. > for(i in 1:length(x)) print(integrate(f,lower=1,upper=4)) 7.021177 with absolute error < 7.8e-14 7.021177 with absolute error < 7.8e-14 7.021177 with absolute error < 7.8e-14 7.021177 with absolute error < 7.8e-14 7.021177 with absolute error < 7.8e-14 AFAIK, integrate computes area below curve defined by function f between lower and upper and it has nothing to do with your x definition. So you should reconsider what do you want to achieve and if you have some time you should read some introduction document(s) to understand how R operates with objects. R Intro should be good starting point. Cheers Petr > -----Original Message----- > From: R-help <r-help-boun...@r-project.org> On Behalf Of malika yassa via R- > help > Sent: Saturday, October 20, 2018 3:04 PM > To: r-help@r-project.org > Subject: [R] (no subject) > > hello > please you help mei 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) > > }but I can not find the vector of resulatwhere is the errorthinks > > [[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. Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních partnerů PRECHEZA a.s. jsou zveřejněny na: https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about processing and protection of business partner’s personal data are available on website: https://www.precheza.cz/en/personal-data-protection-principles/ Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and any documents attached to it may be confidential and are subject to the legally binding disclaimer: https://www.precheza.cz/en/01-disclaimer/ ______________________________________________ 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.