[Rd] documentation / warning when passing a vector as lower/upper bound in stats::integrate()

Baptiste Auguie baptiste.auguie at gmail.com
Tue Mar 29 08:31:02 CEST 2016


Dear R-dev list,

I wonder if stats::integrate shouldn't warn the user when a numeric vector
of length > 1 is passed as lower or upper bounds. If a vector is passed,
only the first value is used and the others are silently ignored:

integrate(sin, lower=0, upper=pi)
integrate(sin, lower=0:10, upper=pi)

?integrate doesn't appear to mention explicitly that the function is not
vectorised over those arguments.

It's probably not a common mistake, but it can have unfortunate
consequences in the iterative calculation of multiple integrals. Someone
was puzzled by this today (http://stackoverflow.com/q/36275909/471093) and
it wasn't immediately obvious what had led to incorrect results (and worse,
it could have gone unnoticed).

Best regards,

baptiste

	[[alternative HTML version deleted]]



More information about the R-devel mailing list