Displaying 1 result from an estimated 1 matches for "integrandtotest".
2005 Sep 16
4
Integrate functions with loops
Hi
i am having a problem with the 'integrate' function
the function i want to integrate has the form
sum(vector^x)
i have defined the function with a for loop first -
integrandtotest <- function(x)
{a<-rep(0,len=2)
for (i in 1:2)
{a[i]<-t[i]^x}
sum(a)
}
the results gives errors
###########
Error in integrate(integrandtotest, lower = 0.1, upper = 2,
subdivisions = 10000) :
evaluation of function gave a result of wrong length
In...