Thats not a very precise question. I'll try anyway.. - if you use c, you need to separate the values by commas - i think you mean seq(1,100,0.1), otherwise x only has one value - function sen is not defined - If you call int(1), upper will be 1, not x[i] - why are you making a function and calling it instead of just : int1[i] <- integrate(H, lower = 0, upper = x[i]) ? - looking at ?integral, you may rather want integral(..)$value
On 30.11.2012, at 13:32, faeriewhisper wrote: > Hi guys! > I have to compute something and i don't know what i'm doing wrong. my code > is a bit complex, but imagine that is something like this: > > a = c(1 2 3 4) > ia = length(a) > > x = seq(1,100,length=0.1) > ib = length(x) > > for(j in 1:ia) { > H = function(x) {sen(x) + a[j]} > for(i in 1:ib) { > int = function(x) { integrate(H, lower = 0, upper = x[i])} > int1[i] = int(1) > } > end > int1 = unlist(int1) > ss[j] = sum(int1) > } > end > > if i try this code without the for loop it's ok, but when i put the cycle > on, i get all sort of errors... > Thank you for your help :) > > > > > > > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/can-t-integrate-in-loop-tp4651416.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > 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 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.