integrate() - parsing args to f()

Henrik Aalborg Nielsen (han@imm.dtu.dk)
Fri, 30 Jan 1998 08:37:34 +0100


Dear S-users,

I've stumbled over a strange behavior of integrate() and I'd like to
hear if any of you has seen similar things for other S+ functions - or
maybe you can tell me where I made the obvious mistake...

>From the help on integrate() I understand that "..." are parsed to f(),
therefore:

> integrand.test.x <- function(z, x) { z - x }
> integrate(f = integrand.test.x, lower=-2, upper=2, x=1)$message
[1] "normal termination"

works. But if 'x' is replaced by 'u' I get the result:

> integrand.test.u <- function(z, u) { z - u }
> integrate(f = integrand.test.u, lower=-2, upper=2, u=1)$message
Error in integrate.f: Missing value where logical needed:
if((!is.na(lower) && aux$lower != lower) || (!is.na(upper) && aux$upper
!=
. . .
Dumped

Note that 'u' is not one of the named arguments to integrate() ...
Anyway, Mathsoft (UK) *thinks* that S+ confuses the 'u' I pass with 'u'
as in 'upper'. Can this really be the case? - If yes: Under what
circumstances do these things happen?

Regards,
Henrik

--
------------------------------------------------------------------------
Henrik Aalborg Nielsen
Department of Mathematical Modelling
Time Series Group                                 Fax:     +45 4588 1397
Technical University of Denmark                   Phone:   +45 4525 3418
Building 321, 2800 Lyngby, Denmark                E-mail: han@imm.dtu.dk
------------------------------------------------------------------------