Full_Name: Travis Porco Version: 1.5.1 (6/17/2002) OS: Suse Linux 7.1 Submission from: (NULL) (66.81.124.235) This happens:> integrate(function(x)1,0,1)Error in integrate(function(x) 1, 0, 1) : evaluation of function gave a result of wrong length> integrate(function(x)x^2,0,1)0.3333333 with absolute error < 3.7e-15> integrate(function(x){cat(x);1},0,1)0.5 0.01304674 0.9869533 0.06746832 0.9325317 0.1602952 0.8397048 0.2833023 0.7166977 0.4255628 0.5744372 0.002171418 0.9978286 0.03492125 0.9650787 0.1095911 0.8904089 0.2186214 0.7813786 0.3528036 0.6471964Error in integrate(function(x){ : evaluation of function gave a result of wrong length This is clearly incorrect behavior. I included case 2 to show that some cases are working correctly. Various other conditions produce the error message indicated. Of course, not being able to integrate a constant is not in itself the problem; rather, function(x)1 generates the same error that occurs in the real problem I'm working on. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>This happens: >> integrate(function(x)1,0,1) >Error in integrate(function(x) 1, 0, 1) : evaluation of function gave a result >of wrong length...>This is clearly incorrect behavior. I included case 2 to show that some cases >are >working correctly.This is user error. The help for integrate says the first argument is "An R function taking a numeric first argument and returning a numeric vector the same length." The function has to return a vector answer when a vector argument is given to it. Duncan Murdoch -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
thanks--i found this out when i looked at the source. i misinterpreted the manual. since i had intended the function to take a scalar and return a scalar, my function seemed to be correct; the intent of the manual page was to have the user write a vectorized function, as you say, to return a vector of function values when a vector of argument values is given to it. --travis -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._