[R] Name conflicts when passing arguments for one function to another

Graham Jones maillists at visiv.co.uk
Sat Jan 29 14:15:54 CET 2005


I am fairly new to R. I find it surprising that

f <- function(x,a) {x-a}
uniroot(f, c(0,1), a=.5)

works, but

integrate(f, 0, 1, a=.5)

gives an error: Error in integrate(f, 0, 1, a = 0.5) : argument 4
matches multiple formal arguments

What is the best way of avoiding such surprises? Is there a way of
telling integrate() that the 'a' argument is for f()?

If I wrote my own function along the lines of uniroot() or integrate()
is there a better way of passing on arguments?

-- 
Graham Jones, author of SharpEye Music Reader
http://www.visiv.co.uk
21e Balnakeil, Durness, Lairg, Sutherland, IV27 4PT, Scotland, UK




More information about the R-help mailing list